public bool Run(CandidateResponseViewModel model, IUnitOfWork unitOfWork, Response <CandidateResponseViewModel> result, ICoreUser CandidateResponse) { var newCustom = CandidateResponseMapper.MapInsertModelToDbModel(model); unitOfWork.With <Database.CandidateResponse>().Add(newCustom); unitOfWork.SaveChanges(); var newCustomResult = CandidateResponseMapper.MapDbModelToViewModel(newCustom); result.Body = newCustomResult; return(true); }
public bool Run(CandidateResponseViewModel model, ref IQueryable <Database.CandidateResponse> repository, IUnitOfWork unitOfWork, Response <CandidateResponseViewModel> result, ICoreUser CandidateResponse) { var dbModel = repository.Single(c => c.JobId == model.JobId && c.CandidateId == model.CandidateId); // you need to be using the primary key could be composit var updatedDbModel = CandidateResponseMapper.MapInsertModelToDbModel(model, dbModel); unitOfWork.With <Database.CandidateResponse>().Update(updatedDbModel); unitOfWork.SaveChanges(); var newCustomResult = CandidateResponseMapper.MapDbModelToViewModel(updatedDbModel); result.Body = newCustomResult; return(true); }
public Response <CandidateResponseViewModel> Run(CandidateResponseViewModel model, ref IQueryable <Database.CandidateResponse> repository, IUnitOfWork unitOfWork, Response <CandidateResponseViewModel> result, ICoreUser CandidateResponse) { var itemToUpdate = repository.SingleOrDefault(c => c.JobId == model.JobId && c.CandidateId == model.CandidateId); if (itemToUpdate != null) { var newCustomResult = CandidateResponseMapper.MapDbModelToViewModel(itemToUpdate); result.Body = newCustomResult; result.Success = true; } else { result.Success = false; result.LogError("Error viewing CandidateResponses"); } return(result); }