Esempio n. 1
0
        public bool Run(EmployerResponseViewModel model, IUnitOfWork unitOfWork, Response <EmployerResponseViewModel> result, ICoreUser EmployerResponse)
        {
            var newCustom = EmployerResponseMapper.MapInsertModelToDbModel(model);

            unitOfWork.With <Database.EmployerResponse>().Add(newCustom);
            unitOfWork.SaveChanges();
            var newCustomResult = EmployerResponseMapper.MapDbModelToViewModel(newCustom);

            result.Body = newCustomResult;
            return(true);
        }
Esempio n. 2
0
        public bool Run(EmployerResponseViewModel model, ref IQueryable <Database.EmployerResponse> repository, IUnitOfWork unitOfWork, Response <EmployerResponseViewModel> result, ICoreUser EmployerResponse)
        {
            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 = EmployerResponseMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <Database.EmployerResponse>().Update(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = EmployerResponseMapper.MapDbModelToViewModel(updatedDbModel);

            result.Body = newCustomResult;
            return(true);
        }
Esempio n. 3
0
        public Response <EmployerResponseViewModel> Run(EmployerResponseViewModel model, ref IQueryable <Database.EmployerResponse> repository, IUnitOfWork unitOfWork, Response <EmployerResponseViewModel> result, ICoreUser EmployerResponse)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.JobId == model.JobId && c.CandidateId == model.CandidateId);

            if (itemToUpdate != null)
            {
                var newCustomResult = EmployerResponseMapper.MapDbModelToViewModel(itemToUpdate);
                result.Body    = newCustomResult;
                result.Success = true;
            }
            else
            {
                result.Success = false;
                result.LogError("Error viewing EmployerResponses");
            }

            return(result);
        }