예제 #1
0
        public ActionResult EducationLevelEdit(int id)
        {
            EducationLevelDTO data = new EducationLevelDTO();

            data = _educationLevelService.GetEducationLevelById(id);
            return(View(data));
        }
예제 #2
0
        public int UpdateEducationLevel(EducationLevelDTO data)
        {
            EducationLevel dataToUpdate = EducationLevelRequestFormatter.ConvertRespondentInfoFromDTO(data);
            var            res          = _unitOfWork.EducationLevelRepository.Update(dataToUpdate);

            _unitOfWork.Save();
            return(res);
        }
예제 #3
0
        public EducationLevelDTO updateEducationLevel(EducationLevelDTO educationLevel)
        {
            var selectedEducationLevel = uow.GetRepository <EducationLevel>().Get(z => z.Id == educationLevel.Id);

            selectedEducationLevel = MapperFactory.CurrentMapper.Map(educationLevel, selectedEducationLevel);
            uow.GetRepository <EducationLevel>().Update(selectedEducationLevel);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EducationLevelDTO>(selectedEducationLevel));
        }
        public HttpResponseMessage Get(int Id)
        {
            EducationLevelDTO selectedTitle = service.getEducationLevel(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
        public HttpResponseMessage Put(EducationLevelDTO accessTypeDTO)
        {
            EducationLevelDTO dto = service.updateEducationLevel(accessTypeDTO);

            if (dto != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
            }
        }
예제 #6
0
 public static EducationLevel ConvertRespondentInfoFromDTO(EducationLevelDTO educationLevelDTO)
 {
     Mapper.CreateMap <EducationLevelDTO, EducationLevel>().ConvertUsing(
         m =>
     {
         return(new EducationLevel
         {
             LevelId = m.LevelId,
             LevelName = m.LevelName,
             LevelOrder = m.LevelOrder
         });
     });
     return(Mapper.Map <EducationLevelDTO, EducationLevel>(educationLevelDTO));
 }
예제 #7
0
 public EducationLevelDTO newEducationLevel(EducationLevelDTO educationLevel)
 {
     if (!uow.GetRepository <EducationLevel>().GetAll().Any(z => z.Id == educationLevel.Id))
     {
         var adedEducationLevel = MapperFactory.CurrentMapper.Map <EducationLevel>(educationLevel);
         adedEducationLevel = uow.GetRepository <EducationLevel>().Add(adedEducationLevel);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <EducationLevelDTO>(adedEducationLevel));
     }
     else
     {
         return(null);
     }
 }
        public HttpResponseMessage Post(EducationLevelDTO accessTypeDTO)
        {
            EducationLevelDTO dto = service.newEducationLevel(accessTypeDTO);

            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.CompanyTitlesControllerStrings.add_title));
            }
        }
예제 #9
0
        public ActionResult EducationLevelCreateClose(EducationLevelDTO data)
        {
            EducationLevelDTO el = new EducationLevelDTO();

            if (!ModelState.IsValid)
            {
                return(View(el));
            }
            try
            {
                EducationLevelDTO res = new EducationLevelDTO();
                res             = _educationLevelService.InsertEducationLevel(data);
                ViewBag.Success = "Education level " + data.LevelName + " has been created successfully";
                return(RedirectToAction("EducationLevel"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View("EducationLevel/Create"));
            }
        }
예제 #10
0
        public RedirectResult EducationLevelEdit(EducationLevelDTO data)
        {
            int res = _educationLevelService.UpdateEducationLevel(data);

            return(Redirect("/educationlevel"));
        }
예제 #11
0
        public EducationLevelDTO InsertEducationLevel(EducationLevelDTO data)
        {
            EducationLevel dataToInsert = EducationLevelRequestFormatter.ConvertRespondentInfoFromDTO(data);

            return(EducationLevelRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.EducationLevelRepository.Create(dataToInsert)));
        }