public CompanyBranchDTO newCompanyBranch(CompanyBranchDTO CompanyBranch) { var adedCompanyBranch = MapperFactory.CurrentMapper.Map <CompanyBranch>(CompanyBranch); adedCompanyBranch = uow.GetRepository <CompanyBranch>().Add(adedCompanyBranch); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <CompanyBranchDTO>(adedCompanyBranch)); }
public CompanyBranchDTO updateCompanyBranch(CompanyBranchDTO CompanyBranch) { var selectedCompanyBranch = uow.GetRepository <CompanyBranch>().Get(z => z.Id == CompanyBranch.Id); selectedCompanyBranch = MapperFactory.CurrentMapper.Map(CompanyBranch, selectedCompanyBranch); uow.GetRepository <CompanyBranch>().Update(selectedCompanyBranch); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <CompanyBranchDTO>(selectedCompanyBranch)); }
public HttpResponseMessage Get(int Id) { CompanyBranchDTO selectedCompanyBranch = service.getCompanyBranch(Id); if (selectedCompanyBranch == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyBranchesControllerStrings.id_branch)); } return(Request.CreateResponse(HttpStatusCode.OK, selectedCompanyBranch)); }
public HttpResponseMessage Put(CompanyBranchDTO CompanyBranchDTO) { CompanyBranchDTO dto = service.updateCompanyBranch(CompanyBranchDTO); if (dto != null) { return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyBranchesControllerStrings.update_branch)); } }
public CompanyBranchDTO newCompanyBranch(CompanyBranchDTO CompanyBranch) { if (!uow.GetRepository <CompanyBranch>().GetAll().Any(z => z.BranchName == CompanyBranch.BranchName)) { var adedCompanyBranch = MapperFactory.CurrentMapper.Map <CompanyBranch>(CompanyBranch); adedCompanyBranch = uow.GetRepository <CompanyBranch>().Add(adedCompanyBranch); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <CompanyBranchDTO>(adedCompanyBranch)); } else { return(null); } }
public HttpResponseMessage Post(CompanyBranchDTO CompanyBranchDTO) { CompanyBranchDTO dto = service.newCompanyBranch(CompanyBranchDTO); if (dto != null) { HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto); message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id); return(message); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyBranchesControllerStrings.add_branch)); } }