public ActionResult Create(AppInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_AppGroupInformation item = new tbl_AppGroupInformation() { CategoryType = viewModel.CategoryType, CategoryName = viewModel.CategoryName, PriceUsage = viewModel.PriceUsage, PointUsage = viewModel.PointUsage, PriceCount = viewModel.PriceCount, PointCount = viewModel.PointCount, InsertDate = DateTime.Now, InsertUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_AppGroupInformation operatorInformationControl = dataOperations.ControlAppGroupInformation(item); if (operatorInformationControl != null) { TempData["success"] = "notOk"; TempData["message"] = "Eyni parametrelerə sahib məlumat sistemdə mövcudur"; return(RedirectToAction("Index")); } else { tbl_AppGroupInformation dbItem = dataOperations.UpdateAppGroupInformation(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) { return(View(viewModel)); } }
public ActionResult Edit(AppInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_AppGroupInformation item = new tbl_AppGroupInformation() { ID = viewModel.ID, CategoryType = viewModel.CategoryType, CategoryName = viewModel.CategoryName, PriceUsage = viewModel.PriceUsage, PointUsage = viewModel.PointUsage, PriceCount = viewModel.PriceCount, PointCount = viewModel.PointCount, UpdateDate = DateTime.Now, UpdateUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_AppGroupInformation dbItem = dataOperations.UpdateAppGroupInformation(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) { return(View(viewModel)); } }
public ActionResult Edit(int id) { AppInformationVM viewModel = new AppInformationVM(); CRUDOperation dataOperations = new CRUDOperation(); tbl_AppGroupInformation tblItem = dataOperations.GetAppGroupInformationById(id); viewModel.ID = id; viewModel.CategoryType = tblItem.CategoryType; viewModel.CategoryName = tblItem.CategoryName; viewModel.PriceUsage = tblItem.PriceUsage == null ? 0 : (decimal)tblItem.PriceUsage; viewModel.PointUsage = tblItem.PointUsage == null ? 0 : (decimal)tblItem.PointUsage; viewModel.PriceCount = tblItem.PriceCount == null ? 0 : (decimal)tblItem.PriceCount; viewModel.PointCount = tblItem.PointCount == null ? 0 : (decimal)tblItem.PointCount; return(View(viewModel)); }