Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }