示例#1
0
        public IActionResult Edit(DtoEmployee employee, string oldPassHash)
        {
            if (ModelState.IsValid && (oldPassHash == null || _service.Read(employee.Id).PassHash == oldPassHash))
            {
                _service.Update(employee.Id, employee);
                return(new ContentResult {
                    Content = employee.ToString(), StatusCode = 200
                });
            }

            return(BadRequest(ModelState));
        }
示例#2
0
        public IActionResult Add(DtoEmployee employee, Guid directorId, Guid departmentDirectorId)
        {
            if (ModelState.IsValid)
            {
                if (directorId != default(Guid))
                {
                    employee.Director = _service.Read(directorId);
                }
                if (departmentDirectorId != default(Guid))
                {
                    employee.DepartmentDirector = _service.Read(departmentDirectorId);
                }
                _service.Create(employee);
                return(new ContentResult {
                    Content = employee.ToString(), StatusCode = 200
                });
            }

            return(BadRequest(ModelState));
        }