public EthnicityDTO InsertEthnicity(EthnicityDTO data) { Ethnicity dataToInsert = new Ethnicity(); dataToInsert = EthnicityRequestFormatter.ConvertRespondentInfoFromDTO(data); return(EthnicityRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.EthnicityRepository.Create(dataToInsert))); }
public ActionResult EthnicityEdit(int id) { EthnicityDTO res = new EthnicityDTO(); res = _ethnicityService.GetEthnicityById(id); return(View(res)); }
public int UpdateEthnicity(EthnicityDTO data) { Ethnicity dataToUpdate = EthnicityRequestFormatter.ConvertRespondentInfoFromDTO(data); int res = _unitOfWork.EthnicityRepository.Update(dataToUpdate); _unitOfWork.Save(); return(res); }
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")); }
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")); }
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)); }
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()); }