Exemplo n.º 1
0
        public bool Run(JobSkillViewModel model, IUnitOfWork unitOfWork, Response <JobSkillViewModel> result, ICoreUser JobSkill)
        {
            var newCustom = JobSkillMapper.MapInsertModelToDbModel(model);

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

            result.Body = newCustomResult;
            return(true);
        }
Exemplo n.º 2
0
        public bool Run(JobSkillViewModel model, ref IQueryable <Database.JobSkill> repository, IUnitOfWork unitOfWork, Response <JobSkillViewModel> result, ICoreUser JobSkill)
        {
            var dbModel        = repository.Single(c => c.JobId == model.JobId && c.SkillId == model.SkillId); // you need to be using the primary key could be composit
            var updatedDbModel = JobSkillMapper.MapInsertModelToDbModel(model, dbModel);

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

            result.Body = newCustomResult;
            return(true);
        }
Exemplo n.º 3
0
        public Response <JobSkillViewModel> Run(JobSkillViewModel model, ref IQueryable <Database.JobSkill> repository, IUnitOfWork unitOfWork, Response <JobSkillViewModel> result, ICoreUser JobSkill)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.JobId == model.JobId && c.SkillId == model.SkillId);

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

            return(result);
        }