public async Task <IActionResult> AddDepV(DepartmentVForUpdateDto departmentVForUpdateDto) { var depToCreate = _mapper.Map <DepartmentV>(departmentVForUpdateDto); depToCreate.Id = Guid.NewGuid(); // depToCreate.RegionId = new Guid("121d5630-83b2-4cf7-8d17-244147238b4e"); depToCreate.Created = DateTime.Now; _repo.Add(depToCreate); if (await _repo.SaveAll()) { return(Ok(depToCreate)); } return(BadRequest()); //return Ok(); }
public async Task <IActionResult> UpdateDepV(Guid id, DepartmentVForUpdateDto departmentVForUpdateDto) { var depVFromRepo = await _depRepo.GetDepartmentV(id); _mapper.Map(departmentVForUpdateDto, depVFromRepo); try { if (await _repo.SaveAll()) { return(NoContent()); } } catch (Exception ex) { ex.ToString(); throw; } throw new Exception($"Updating departmentV {id} failed on save"); }