-
-
Save Chizh/6bee6c618bc8ff586d62c77a0d879474 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MongoDB.Bson; | |
namespace RetailRocket.PartnerOffice.Controllers | |
{ | |
using System.Collections.Generic; | |
using System.Web.Mvc; | |
public class EmployeesExportController : Controller | |
{ | |
} | |
[Authorize] | |
public class EmployeesController : Controller | |
{ | |
public EmployeesController() | |
{ | |
} | |
public ActionResult List(ListRequestModel request) | |
{ | |
return this.View( | |
new EmployeesListViewModel( | |
employees: new List<Employee>())); | |
} | |
public ActionResult Get(EmployeeId employeeId) | |
{ | |
return this.View(new EmployeeViewModel()); | |
} | |
public ActionResult Delete(EmployeeId employeeId) | |
{ | |
return this.RedirectToAction(actionName: "List"); | |
} | |
/// ??? | |
public ActionResult Patch(EmployeeId employeeId) | |
{ | |
return this.RedirectToAction( | |
actionName: "Get", | |
routeValues: new { employeeId = employeeId }); | |
} | |
public ActionResult Post(PostEmployeeRequestModel request) | |
{ | |
var employee = new Employee | |
{ | |
Id = new EmployeeId(ObjectId.GenerateNewId()), | |
Name = request.Name | |
}; | |
// saving... | |
return this.RedirectToAction( | |
actionName: "Get", | |
routeValues: new { employeeId = employee.Id }); | |
} | |
public class ListRequestModel | |
{ | |
private string DepartmentNameFilter { get; set; } | |
private string GenderFilter { get; set; } | |
} | |
public class EmployeesListViewModel | |
{ | |
public EmployeesListViewModel(List<Employee> employees) | |
{ | |
this.Employees = employees; | |
} | |
public List<Employee> Employees { get; set; } | |
} | |
public class Employee | |
{ | |
public EmployeeId Id { get; set; } | |
public string Name { get; set; } | |
} | |
public class Id<T> | |
{ | |
private readonly T value; | |
public Id(T value) | |
{ | |
this.value = value; | |
} | |
} | |
public class EmployeeId : Id<ObjectId> | |
{ | |
public EmployeeId(ObjectId value) | |
: base(value) | |
{ | |
} | |
} | |
public class PostEmployeeRequestModel | |
{ | |
public string Name { get; set; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment