public ActionResult Create(TypeVM typeViewModel) { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { tbl_Type typeItem = new tbl_Type() { Name = typeViewModel.Name, Description = typeViewModel.Description, InsertUser = UserProfile.UserId }; DataOperations dateOperation = new DataOperations(); tbl_Type typeDB = dateOperation.AddType(typeItem); if (typeDB != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla əlavə olundu"; } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi"; } } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { DataOperations dataOperations = new DataOperations(); tbl_Type typleDB = dataOperations.GetTypeById(id); TypeVM viewModel = new TypeVM() { ID = typleDB.ID, Name = typleDB.Name, ParentID = typleDB.ParentID, Description = typleDB.Description }; viewModel = poulateParentList(viewModel); return(View(viewModel)); } return(null); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Error", "Error"))); } }
public ActionResult CreateSubMenu(int id) { TypeVM typeViewModel = new TypeVM(); typeViewModel.ParentID = id; typeViewModel = poulateParentList(typeViewModel); return(View(typeViewModel)); }
public async Task <IViewComponentResult> InvokeAsync() { var data = new TypeVM(); data.typeViewModels = await _typeService.GetAll(); return(View(data)); }
public bool Insert(TypeVM typeVM) { if (string.IsNullOrWhiteSpace(typeVM.Name)) { return(status); } else { return(iTypeRepository.Insert(typeVM)); } }
public bool Update(int id, TypeVM typeVM) { var get = Get(id); if (get != null) { get.Update(id, typeVM); myContext.Entry(get).State = EntityState.Modified; myContext.SaveChanges(); return(true); } else { return(false); } }
public ActionResult Edit(TypeVM viewModel) { try { DataOperations dataOperations = new DataOperations(); var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (!ModelState.IsValid) { return(View(viewModel)); } int parentID = viewModel.ParentID == null ? 0 : (int)viewModel.ParentID; tbl_Type type = new tbl_Type() { ID = (int)viewModel.ID, ParentID = parentID, Name = viewModel.Name, Description = viewModel.Description, UpdateUser = UserProfile.UserId }; tbl_Type updatedItemDB = dataOperations.UpdateType(type); if (updatedItemDB != 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")); } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Error", "Error"))); } }
public bool Insert(TypeVM typeVM) { var push = new TypeItem(typeVM); myContext.Type.Add(push); var result = myContext.SaveChanges(); if (result > 0) { status = true; } else { return(status); } return(status); }
public ActionResult Detail(int id) { TypeVM typeViewModel = new TypeVM(); TypeRepository repository = new TypeRepository(); DataOperations dataOperations = new DataOperations(); TypeDTO typeDTO = repository.GetTypeDTOByID(id); typeViewModel.ParentID = typeDTO.ParentID; typeViewModel.ParentName = typeDTO.ParentTypeName; typeViewModel.ID = typeDTO.ID; typeViewModel.Name = typeDTO.Name; typeViewModel.Description = typeDTO.Description; if (typeDTO != null) { typeViewModel.RTypeList = dataOperations.GetTypeByParentId(typeDTO.ID); } return(PartialView(typeViewModel)); }
// GET: Type public ActionResult Index(int?page, int?vehicleId, string vl, string prm = null) { try { TypeRepository repository = new TypeRepository(); TypeVM viewModel = new TypeVM(); Search search = new Search(); search = SetValue(page, vl, prm); int pageSize = 15; int pageNumber = (page ?? 1); viewModel.Search = search; viewModel.Search = search; viewModel.Search.pageSize = pageSize; viewModel.Search.pageNumber = pageNumber; viewModel.RTypeDTOList = repository.SW_GetTypes(viewModel.Search); viewModel.ListCount = repository.SW_GetTypesCount(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"))); } }
public void Update(int id, TypeVM typeVM) { this.Id = id; this.Name = typeVM.Name; this.UpdateDate = DateTimeOffset.Now.ToLocalTime(); }
public TypeItem(TypeVM typeVM) { this.Name = typeVM.Name; this.CreateDate = DateTimeOffset.Now.ToLocalTime(); }
public bool Update(int id, TypeVM typeVM) { return(iTypeRepository.Update(id, typeVM)); }
public TypeVM poulateParentList(TypeVM typeViewModel) { typeViewModel.ParentList = EnumService.GetTypeEnumParentList(); return(typeViewModel); }