public ActionResult Create() { OperatorInformationVM viewModel = new OperatorInformationVM(); viewModel = poulateDropDownList(viewModel); return(View(viewModel)); }
public ActionResult Create(OperatorInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_OperatorInformation item = new tbl_OperatorInformation() { OperatorType_EVID = viewModel.OperatorTypeEVID, Name = viewModel.Name, OperatorChanelType_EVID = viewModel.OperatorChanelTypeEVID, InOutType_EVID = viewModel.InOutTypeEVID, Price = viewModel.Price, Point = viewModel.Point, InsertDate = DateTime.Now, InsertUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation operatorInformationControl = dataOperations.ControlOperatorInformation(item); if (operatorInformationControl != null) { TempData["success"] = "notOk"; TempData["message"] = "Eyni parametrelerə sahib məlumat sistemdə mövcudur"; return(RedirectToAction("Index")); } else { tbl_OperatorInformation dbItem = dataOperations.AddOperatorInformation(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla əlavə olundu"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi"; return(RedirectToAction("Index")); } } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
private OperatorInformationVM poulateDropDownList(OperatorInformationVM viewModel) { viewModel.OperatorTypeList = EnumService.GetEnumValueListByEcID((int)CategoryEnum.OperatorType); viewModel.OperatorChanelTypeList = EnumService.GetEnumValueListByEcID((int)CategoryEnum.OperatorChanelType); if (viewModel.EnumCategoryID == 17) { viewModel.InOutTypeList = EnumService.GetEnumValueListByEcIDForINOUT((int)CategoryEnum.InOutTypeMessage); } else { viewModel.InOutTypeList = EnumService.GetEnumValueListByEcIDForINOUT((int)CategoryEnum.InOutTypeCall); } viewModel.OperatorPrefixList = EnumService.GetEnumValueListByEcIDForPrefix((int)CategoryEnum.OperatorPrefixType); return(viewModel); }
public ActionResult Edit(OperatorInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_OperatorInformation item = new tbl_OperatorInformation() { ID = viewModel.ID, OperatorType_EVID = viewModel.OperatorTypeEVID, Name = viewModel.Name, OperatorChanelType_EVID = viewModel.OperatorChanelTypeEVID, InOutType_EVID = viewModel.InOutTypeEVID, Price = viewModel.Price, Point = viewModel.Point, UpdateDate = DateTime.Now, UpdateUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation dbItem = dataOperations.UpdateOperatorInformation(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla dəyişdirildi"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar dəyişdirilərkən xəta baş verdi"; return(RedirectToAction("Index")); } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
public ActionResult Edit(int id) { OperatorInformationVM viewModel = new OperatorInformationVM(); CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation tblItem = dataOperations.GetOperatorInformationById(id); tbl_EnumValue enumValue = dataOperations.GetEnumValueById((int)tblItem.OperatorChanelType_EVID); viewModel.EnumCategoryID = enumValue.EnumCategoryID; viewModel = poulateDropDownList(viewModel); viewModel.ID = id; viewModel.OperatorTypeEVID = tblItem.OperatorType_EVID == null?0:(int)tblItem.OperatorType_EVID; viewModel.Name = tblItem.Name; viewModel.OperatorChanelTypeEVID = tblItem.OperatorChanelType_EVID == null ? 0 : (int)tblItem.OperatorChanelType_EVID; viewModel.InOutTypeEVID = tblItem.InOutType_EVID == null ? 0 : (int)tblItem.InOutType_EVID; viewModel.Price = tblItem.Price == null?0:(decimal)tblItem.Price; viewModel.Point = tblItem.Point == null ? 0 : (decimal)tblItem.Point; return(View(viewModel)); }
public ActionResult Index(int?page, string vl, string prm = null) { OperatorInformationRepository repository = new OperatorInformationRepository(); try { Search search = new Search(); search = SetValue(page, vl, prm); int pageSize = 15; int pageNumber = (page ?? 1); OperatorInformationVM viewModel = new OperatorInformationVM(); viewModel.Search = search; viewModel.Search.pageSize = pageSize; viewModel.Search.pageNumber = pageNumber; viewModel.ROperatorInformationList = repository.SW_GetOperatorInformations(viewModel.Search); viewModel.ListCount = repository.SW_GetOperatorInformationsCount(viewModel.Search); int[] pc = new int[viewModel.ListCount]; viewModel.Paging = pc.ToPagedList(pageNumber, pageSize); return(Request.IsAjaxRequest() ? (ActionResult)PartialView("PartialIndex", viewModel) : View(viewModel)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Error", "Error"))); } }