Exemplo n.º 1
0
        public EthnicityDTO InsertEthnicity(EthnicityDTO data)
        {
            Ethnicity dataToInsert = new Ethnicity();

            dataToInsert = EthnicityRequestFormatter.ConvertRespondentInfoFromDTO(data);
            return(EthnicityRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.EthnicityRepository.Create(dataToInsert)));
        }
Exemplo n.º 2
0
        public ActionResult EthnicityEdit(int id)
        {
            EthnicityDTO res = new EthnicityDTO();

            res = _ethnicityService.GetEthnicityById(id);
            return(View(res));
        }
Exemplo n.º 3
0
        public int UpdateEthnicity(EthnicityDTO data)
        {
            Ethnicity dataToUpdate = EthnicityRequestFormatter.ConvertRespondentInfoFromDTO(data);
            int       res          = _unitOfWork.EthnicityRepository.Update(dataToUpdate);

            _unitOfWork.Save();
            return(res);
        }
Exemplo n.º 4
0
        public ActionResult EthnicityEdit(EthnicityDTO data)
        {
            EthnicityDTO ed = new EthnicityDTO();

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("EthnicityEdit", ed));
            }
            int res = _ethnicityService.UpdateEthnicity(data);

            return(RedirectToAction("Ethnicity", "Ethnicity"));
        }
Exemplo n.º 5
0
        public ActionResult EthnicityCreateClose(EthnicityDTO data)
        {
            EthnicityDTO ed = new EthnicityDTO();

            if (!ModelState.IsValid)
            {
                return(View("Ethnicity/Create", ed));
            }
            EthnicityDTO res = _ethnicityService.InsertEthnicity(data);

            return(RedirectToAction("Ethnicity", "Ethnicity"));
        }
Exemplo n.º 6
0
 public static Ethnicity ConvertRespondentInfoFromDTO(EthnicityDTO ethnicityDTO)
 {
     Mapper.CreateMap <EthnicityDTO, Ethnicity>().ConvertUsing(
         m =>
     {
         return(new Ethnicity
         {
             EthnicityName = m.EthnicityName,
             EthnicityId = m.EthnicityId
         });
     });
     return(Mapper.Map <EthnicityDTO, Ethnicity>(ethnicityDTO));
 }
Exemplo n.º 7
0
        public ActionResult EthnicityCreate(EthnicityDTO data)
        {
            EthnicityDTO ed = new EthnicityDTO();

            if (!ModelState.IsValid)
            {
                return(View(ed));
            }
            EthnicityDTO res = _ethnicityService.InsertEthnicity(data);

            ViewBag.Success = "Ethnicity " + res.EthnicityName + " has been created.";
            ModelState.Clear();
            return(View());
        }