示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
 private void Awake()
 {
     Instance = this;
 }