Skip to content

Instantly share code, notes, and snippets.

@Chizh
Created August 9, 2017 12:26
Show Gist options
  • Save Chizh/6bee6c618bc8ff586d62c77a0d879474 to your computer and use it in GitHub Desktop.
Save Chizh/6bee6c618bc8ff586d62c77a0d879474 to your computer and use it in GitHub Desktop.
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