public ActionResult Edit(UserContactTypeDto model) { ResultHelper result = JsonConvert.DeserializeObject <ResultHelper>(userContactTypeService.SetUserContactType(model)); ViewBag.Message = Helper.GetResultMessage(result.Result, result.ResultDescription); return(View()); }
public ResultHelper AddUserContactType(UserContactTypeDto userContactTypeDto) { try { if (IsThere(userContactTypeDto)) { return(new ResultHelper(false, 0, ResultHelper.SuccessMessage)); } usercontacttype item = new usercontacttype(); item.UserContactTypeID = userContactTypeDto.UserContactTypeID; item.TypeName = userContactTypeDto.TypeName; item.Description = userContactTypeDto.Description; using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.GetRepository <usercontacttype>().Insert(item); unitOfWork.saveChanges(); return(new ResultHelper(true, item.UserContactTypeID, ResultHelper.SuccessMessage)); } } catch (Exception ex) { return(new ResultHelper(false, 0, ResultHelper.UnSuccessMessage)); } }
public bool IsThere(UserContactTypeDto userContactTypeDto) { using (UnitOfWork unitofWork = new UnitOfWork()) { var item = unitofWork.GetRepository <usercontacttype>().GetById(x => x.UserContactTypeID == userContactTypeDto.UserContactTypeID && x.TypeName == userContactTypeDto.TypeName && x.Description == userContactTypeDto.Description); if (item != null) { return(true); } else { return(false); } } }
public UserContactTypeDto GetUserContactType(int userContactTypeID) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { usercontacttype item = new usercontacttype(); item = unitOfWork.GetRepository <usercontacttype>().GetById(x => x.UserContactTypeID == userContactTypeID); UserContactTypeDto userContactTypeDto = new UserContactTypeDto(); userContactTypeDto.TypeName = item.TypeName; userContactTypeDto.UserContactTypeID = item.UserContactTypeID; userContactTypeDto.Description = item.Description; return(userContactTypeDto); } } catch (Exception) { return(null); } }
public string SetUserContactType(UserContactTypeDto userContactTypeDto) { return(JsonConvert.SerializeObject(userContactTypeLogic.SetUserContactType(userContactTypeDto))); }