public IHttpActionResult DeleteProfession(int id) { try { UnitOfWork unitOfWork = new UnitOfWork(factory); Profession profession = unitOfWork.ProfessionsRepository .Get(d => d.Id == id, includeProperties: "Country") .FirstOrDefault(); profession.Deleted = true; unitOfWork.ProfessionsRepository.Update(profession); unitOfWork.Save(); ProfessionDTO dto = profession.ToDTO(); return(Ok(dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult PutProfession(int id, ProfessionDTO profession) { if (profession == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != profession.Id) { return(BadRequest()); } try { Profession prof = profession.FromDTO(); UnitOfWork unitOfWork = new UnitOfWork(factory); unitOfWork.ProfessionsRepository.Update(prof); unitOfWork.Save(); ProfessionDTO dto = unitOfWork.ProfessionsRepository .Get(d => d.Id == id, includeProperties: "Country") .FirstOrDefault().ToDTO(); return(Ok(dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult PostProfession(ProfessionDTO profession) { if (profession == null) { return(BadRequest(ModelState)); } try { Profession prof = profession.FromDTO(); UnitOfWork unitOfWork = new UnitOfWork(factory); prof.Id = prof.NewId(unitOfWork); unitOfWork.ProfessionsRepository.Insert(prof); unitOfWork.Save(); ProfessionDTO dto = unitOfWork.ProfessionsRepository .Get(d => d.Id == prof.Id, includeProperties: "Country") .FirstOrDefault().ToDTO(); return(CreatedAtRoute("GetProfession", new { id = dto.Id }, dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public static Professions professionToDal(ProfessionDTO profession) { return(new Professions() { ProfessionId = profession.ProfessionId, ProfessionName = profession.ProfessionName, baseprofessionId = profession.BaseProfessionId }); }
//===============profession============== public static Profession ProfessionDtoToDal(ProfessionDTO p) { return(new Profession { UserId = p.UserId, ProfessionName = p.ProfessionName, MoneyForHour = p.MoneyForHour }); }
public Profession ConvertToEF(ProfessionDTO DTO) { var EF = new Profession() { ProfessionId = DTO.ProfessionId, PFCareerId = DTO.PFCareerId, PFName = DTO.PFName, }; if (DTO.CareerDTO != null) { EF.Career = new ConvertDataCareer().ConvertToEF(DTO.CareerDTO); } return(EF); }
public ProfessionDTO ConvertToDTO(Profession EF) { var DTO = new ProfessionDTO() { ProfessionId = EF.ProfessionId, PFCareerId = EF.PFCareerId, PFName = EF.PFName }; if (EF.Career != null) { DTO.CareerDTO = new ConvertDataCareer().ConvertToDTO(EF.Career); } return(DTO); }
public ActionResult Delete([FromBody] ProfessionDTO professionDTO) { try { if (professionDTO == null) { return(NotFound()); } _applicationServiceProfession.Remove(professionDTO); return(Ok("Profession deleted!")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult Put([FromBody] ProfessionDTO professionDTO) { try { if (professionDTO == null) { return(NotFound()); } _applicationServiceProfession.Update(professionDTO); return(Ok("Profession updated!")); } catch (Exception e) { //throw e; return(BadRequest(e.Message)); } }
public void Update(ProfessionDTO obj) { var profession = _mapper.Map <Profession>(obj); _serviceProfession.Update(profession); }
public void Remove(ProfessionDTO obj) { var profession = _mapper.Map <Profession>(obj); _serviceProfession.Remove(profession); }
public void Add(ProfessionDTO obj) { var profession = _mapper.Map <Profession>(obj); _serviceProfession.Add(profession); }