public bool Update(SupSpecailization S_Specailize) { if (S_Specailize == null) { throw new ArgumentNullException(); } bool result = false; var SupSpecial = Mapper.Map <SupSpecialization>(S_Specailize); TheUnitOfWork.SupSpecializationRepo.Update(SupSpecial); result = TheUnitOfWork.SaveChanges() > new int(); return(result); }
public SupSpecailization Insert(SupSpecailization SupSDTO, bool byAdmin) { if (SupSDTO == null) { throw new ArgumentNullException(); } SupSpecialization sup_specilize = Mapper.Map <SupSpecialization>(SupSDTO); sup_specilize.ByAdmin = byAdmin; TheUnitOfWork.SupSpecializationRepo.Insert(sup_specilize); TheUnitOfWork.SaveChanges(); SupSDTO.ID = sup_specilize.ID; return(SupSDTO); }
public IActionResult Update(int id, SupSpecailization SupSDTO) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } if (id != SupSDTO.ID) { return(BadRequest()); } try { _supSpecializationAppService.Update(SupSDTO); _generalAppService.CommitTransaction(); return(NoContent()); } catch (Exception ex) { _generalAppService.RollbackTransaction(); return(BadRequest(ex.Message)); } }
public IActionResult Create(SupSpecailization createSupSpecailizationDtoDTO) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } try { if (_supSpecializationAppService.CheckExistsByName(createSupSpecailizationDtoDTO)) { return(BadRequest("The SupSpecialize Is Already Exist")); } } catch (Exception ex) { return(BadRequest(ex.Message)); } try { SupSpecailization newSupDTO; string userRole = HttpContext.User.FindFirst(ClaimTypes.Role).Value; if (userRole == UserRoles.Admin) { newSupDTO = _supSpecializationAppService.Insert(createSupSpecailizationDtoDTO, true); } else { newSupDTO = _supSpecializationAppService.Insert(createSupSpecailizationDtoDTO, false); } _generalAppService.CommitTransaction(); return(Created("SubSpecail created", newSupDTO)); } catch (Exception ex) { _generalAppService.RollbackTransaction(); return(BadRequest(ex.Message)); } }
public bool CheckExistsByName(SupSpecailization SupSDTO) { SupSpecialization SupSpecial = Mapper.Map <SupSpecialization>(SupSDTO); return(TheUnitOfWork.SupSpecializationRepo.CheckExistByName(SupSpecial)); }