public ActionResult DepartmentEdit(EditDepartment model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateAdministrationService(); if (service.EditDepartment(model.DepartmentID, model)) { return(RedirectToAction("Departments")); } return(View(model)); }
public EditDepartment GetDepartment(int id) { Departments department = ctx.Departments.Single(e => e.CompanyID == _companyID && e.DepartmentID == id); EditDepartment editDepartment = new EditDepartment { DepartmentID = department.DepartmentID, DepartmentName = department.DepartmentName, }; CreateHistory history = new CreateHistory { CompanyID = _companyID, UserID = _userID.ToString(), Table = "Departments", Method = $"GetDepartment()", stringID = id.ToString(), Request = "GetDepartment()", }; AddHistory(history); return(editDepartment); }
public bool EditDepartment(int id, EditDepartment model) { Departments departments = ctx.Departments.Find(id); if (departments == null) { return(false); } departments.DepartmentName = model.DepartmentName; departments.ModifiedDateUTC = DateTimeOffset.UtcNow; CreateHistory history = new CreateHistory { CompanyID = _companyID, UserID = _userID.ToString(), Table = "Departments", Method = $"EditDepartment({id}, EditDepartment model)", stringID = id.ToString(), Request = Newtonsoft.Json.JsonConvert.SerializeObject(model) }; return(AddHistory(history)); }
private void Awake() { Instance = this; }