Skip to content

Commit 52f50be

Browse files
Update to 25.1.3+
1 parent 74d5cab commit 52f50be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2879
-22
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace ASP_NET_Core.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public IActionResult Index()
12+
{
13+
return View();
14+
}
15+
16+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
17+
public IActionResult Error() {
18+
return View();
19+
}
20+
}
21+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Net.Http;
6+
using System.Xml.Linq;
7+
using ASP.NET_Core.Models;
8+
using ASP_NET_Core.Models;
9+
using DevExtreme.AspNet.Data;
10+
using DevExtreme.AspNet.Mvc;
11+
using Microsoft.AspNetCore.Mvc;
12+
using Newtonsoft.Json;
13+
using ASP_NET_Core.Extensions;
14+
15+
namespace ASP_NET_Core.Controllers {
16+
17+
[Route("api/[controller]")]
18+
public class SampleDataController : Controller {
19+
20+
[HttpGet]
21+
public object Get(DataSourceLoadOptions loadOptions) {
22+
return DataSourceLoader.Load(EmployeeStore.Employees, loadOptions);
23+
}
24+
[HttpPost]
25+
public IActionResult Add(string values) {
26+
var newEmployee = new Employee();
27+
JsonConvert.PopulateObject(values, newEmployee);
28+
29+
if (!TryValidateModel(newEmployee))
30+
return BadRequest(ModelState.GetFullErrorMessage());
31+
32+
EmployeeStore.Employees.Add(newEmployee);
33+
34+
return Ok();
35+
}
36+
37+
[HttpPut]
38+
public IActionResult Update(int key, string values) {
39+
var employee = EmployeeStore.Employees.First(a => a.ID == key);
40+
JsonConvert.PopulateObject(values, employee);
41+
42+
if (!TryValidateModel(employee))
43+
return BadRequest(ModelState.GetFullErrorMessage());
44+
45+
return Ok();
46+
}
47+
48+
[HttpDelete]
49+
public void Delete(int key) {
50+
var employee = EmployeeStore.Employees.First(a => a.ID == key);
51+
EmployeeStore.Employees.Remove(employee);
52+
}
53+
}
54+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Mvc.ModelBinding;
2+
using System.Collections.Generic;
3+
using System;
4+
5+
namespace ASP_NET_Core.Extensions
6+
{
7+
static class Extensions {
8+
public static string GetFullErrorMessage(this ModelStateDictionary modelState) {
9+
var messages = new List<string>();
10+
11+
foreach (var entry in modelState) {
12+
foreach (var error in entry.Value.Errors)
13+
messages.Add(error.ErrorMessage);
14+
}
15+
16+
return String.Join(" ", messages);
17+
}
18+
}
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Xml.Linq;
5+
using System;
6+
7+
namespace ASP_NET_Core.Models {
8+
public class Employee
9+
{
10+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "ID")]
11+
public int ID { get; set; }
12+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "FirstName")]
13+
[Required(ErrorMessage = "First Name is required.")]
14+
public string FirstName { get; set; }
15+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "LastName")]
16+
[Required(ErrorMessage = "Last Name is required.")]
17+
public string LastName { get; set; }
18+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Prefix")]
19+
public string Prefix { get; set; }
20+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Position")]
21+
public string Position { get; set; }
22+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "BirthDate")]
23+
[Required(ErrorMessage = "Birth Date is required.")]
24+
public DateTime? BirthDate { get; set; }
25+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "HireDate")]
26+
public DateTime? HireDate { get; set; }
27+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Notes")]
28+
public string Notes { get; set; }
29+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Address")]
30+
public string Address { get; set; }
31+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Phone")]
32+
[Required(ErrorMessage = "Phone Number is required.")]
33+
public string Phone { get; set; }
34+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "Email")]
35+
[EmailAddress(ErrorMessage = "Email is incorrect.")]
36+
public string Email { get; set; }
37+
}
38+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
using ASP_NET_Core.Models;
2+
using DevExtreme.AspNet.Mvc;
3+
using System.Collections.Generic;
4+
using System.Net;
5+
using System.Numerics;
6+
7+
namespace ASP.NET_Core.Models
8+
{
9+
static class EmployeeStore {
10+
public static List<Employee> Employees = new List<Employee>() {
11+
new Employee() {
12+
ID = 1,
13+
FirstName = "John",
14+
LastName = "Heart",
15+
Prefix = "Mr.",
16+
Position = "CEO",
17+
BirthDate = System.DateTime.Parse("1964/03/16"),
18+
HireDate = System.DateTime.Parse("1995/01/15"),
19+
Notes = "John has been in the Audio/Video industry since 1990. He has led DevAv as its CEO since 2003.\r\n\r\nWhen not working hard as the CEO, John loves to golf and bowl. He once bowled a perfect game of 300.",
20+
Address = "351 S Hill St.",
21+
Phone = "16102458448",
22+
Email = "[email protected]",
23+
}, new Employee() {
24+
ID = 2,
25+
FirstName = "Olivia",
26+
LastName = "Peyton",
27+
Prefix = "Mrs.",
28+
Position = "Sales Assistant",
29+
BirthDate = System.DateTime.Parse("1981/06/03"),
30+
HireDate = System.DateTime.Parse("2012/05/14"),
31+
Notes = "Olivia loves to sell. She has been selling DevAV products since 2012. \r\n\r\nOlivia was homecoming queen in high school. She is expecting her first child in 6 months. Good Luck Olivia.",
32+
Address = "807 W Paseo Del Mar",
33+
Phone = "16102347905",
34+
Email = "[email protected]",
35+
}, new Employee() {
36+
ID = 3,
37+
FirstName = "Robert",
38+
LastName = "Reagan",
39+
Prefix = "Mr.",
40+
Position = "CMO",
41+
BirthDate = System.DateTime.Parse("1974/09/07"),
42+
HireDate = System.DateTime.Parse("2002/11/08"),
43+
Notes = "Robert was recently voted the CMO of the year by CMO Magazine. He is a proud member of the DevAV Management Team.\r\n\r\nRobert is a championship BBQ chef, so when you get the chance ask him for his secret recipe.",
44+
Address = "4 Westmoreland Pl.",
45+
Phone = "14845219762",
46+
Email = "[email protected]",
47+
}, new Employee() {
48+
ID = 4,
49+
FirstName = "Greta",
50+
LastName = "Sims",
51+
Prefix = "Ms.",
52+
Position = "HR Manager",
53+
BirthDate = System.DateTime.Parse("1977/11/22"),
54+
HireDate = System.DateTime.Parse("1998/04/23"),
55+
Notes = "Greta has been DevAV's HR Manager since 2003. She joined DevAV from Sonee Corp.\r\n\r\nGreta is currently training for the NYC marathon. Her best marathon time is 4 hours. Go Greta.",
56+
Address = "1700 S Grandview Dr.",
57+
Phone = "14844578858",
58+
Email = "[email protected]",
59+
}, new Employee() {
60+
ID = 5,
61+
FirstName = "Brett",
62+
LastName = "Wade",
63+
Prefix = "Mr.",
64+
Position = "IT Manager",
65+
BirthDate = System.DateTime.Parse("1968/12/01"),
66+
HireDate = System.DateTime.Parse("2009/03/06"),
67+
Notes = "Brett came to DevAv from Microsoft and has led our IT department since 2012.\r\n\r\nWhen he is not working hard for DevAV, he coaches Little League (he was a high school pitcher).",
68+
Address = "1120 Old Mill Rd.",
69+
Phone = "18143008837",
70+
Email = "[email protected]",
71+
}, new Employee() {
72+
ID = 6,
73+
FirstName = "Sandra",
74+
LastName = "Johnson",
75+
Prefix = "Mrs.",
76+
Position = "Controller",
77+
BirthDate = System.DateTime.Parse("1974/11/15"),
78+
HireDate = System.DateTime.Parse("2005/05/11"),
79+
Notes = "Sandra is a CPA and has been our controller since 2008. She loves to interact with staff so if you've not met her, be certain to say hi.\r\n\r\nSandra has 2 daughters both of whom are accomplished gymnasts.",
80+
Address = "4600 N Virginia Rd.",
81+
Phone = "15852826538",
82+
Email = "[email protected]",
83+
}, new Employee() {
84+
ID = 7,
85+
FirstName = "Kevin",
86+
LastName = "Carter",
87+
Prefix = "Mr.",
88+
Position = "Shipping Manager",
89+
BirthDate = System.DateTime.Parse("1978/01/09"),
90+
HireDate = System.DateTime.Parse("2009/08/11"),
91+
Notes = "Kevin is our hard-working shipping manager and has been helping that department work like clockwork for 18 months.\r\n\r\nWhen not in the office, he is usually on the basketball court playing pick-up games.",
92+
Address = "424 N Main St.",
93+
Phone = "14844760152",
94+
Email = "[email protected]",
95+
}, new Employee() {
96+
ID = 8,
97+
FirstName = "Cynthia",
98+
LastName = "Stanwick",
99+
Prefix = "Ms.",
100+
Position = "HR Manager",
101+
BirthDate = System.DateTime.Parse("1985/06/05"),
102+
HireDate = System.DateTime.Parse("2008/03/24"),
103+
Notes = "Cindy joined us in 2008 and has been in the HR department for 2 years. \r\n\r\nShe was recently awarded employee of the month. Way to go Cindy!",
104+
Address = "2211 Bonita Dr.",
105+
Phone = "14842989304",
106+
Email = "[email protected]",
107+
}, new Employee() {
108+
ID = 9,
109+
FirstName = "Kent",
110+
LastName = "Samuelson",
111+
Prefix = "Dr.",
112+
Position = "Support Manager",
113+
BirthDate = System.DateTime.Parse("1972/09/11"),
114+
HireDate = System.DateTime.Parse("2009/04/22"),
115+
Notes = "As our ombudsman, Kent is on the front-lines solving customer problems and helping our partners address issues out in the field. He is a classically trained musician and is a member of the Chamber Orchestra.",
116+
Address = "12100 Mora Dr",
117+
Phone = "14844731660",
118+
Email = "[email protected]",
119+
}, new Employee() {
120+
ID = 10,
121+
FirstName = "Taylor",
122+
LastName = "Riley",
123+
Prefix = "Mr.",
124+
Position = "Sales Manager",
125+
BirthDate = System.DateTime.Parse("1982/08/14"),
126+
HireDate = System.DateTime.Parse("2012/04/14"),
127+
Notes = "If you are like the rest of us at DevAV, then you've probably reached out for help from Taylor. He does a great job as a member of our IT department.",
128+
Address = "7776 Torreyson Dr",
129+
Phone = "14842989306",
130+
Email = "[email protected]",
131+
}
132+
};
133+
}
134+
}

0 commit comments

Comments
 (0)