public ActionResult Edit(int id, FormCollection collection) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } try { // TODO: Add update logic here AbonentModel theAbonent = new AbonentModel(); theAbonent.ID = id; theAbonent.Name = collection["Name"]; theAbonent.Phone = collection["Phone"]; theAbonent.Description = collection["Description"]; theAbonent.Email = collection["Email"]; theAbonent.BranchID = Convert.ToInt32(collection["BranchID"]); if (theAbonent.BranchID == 0) { UserModel theUser = new UserModel(); theAbonent.BranchID = theUser.FindByID(UserModel.CurrentUserId).BrancheID; } theAbonent.Update(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View()); } }
public ActionResult Create(FormCollection collection) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } try { // TODO: Add insert logic here AbonentModel theAbonent = new AbonentModel(); //theAbonent.ID = Convert.ToInt32(collection["ID"]); theAbonent.Name = collection["Name"]; theAbonent.Phone = collection["Phone"]; theAbonent.Description = collection["Description"]; theAbonent.Email = collection["Email"]; theAbonent.Create(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View()); } }
public ActionResult Index(int id = 0) { //var listDataTarifs = entityWork.GetTarifs(); var abonentsModel = new AbonentModel { Abonents = entityWork.GetAbonents(PageSize, id) }; return(View(abonentsModel)); }
// // GET: /Abonents/Details/5 public ActionResult Details(int id) { if (!AccessActions.IsAccess("Abonents::Read")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } AbonentModel theAbonent = new AbonentModel(); theAbonent.FindOne(id); return(View(theAbonent)); }
public JsonResult IsAbonentPhone_Available(string Phone) { AbonentModel theAbonents = new AbonentModel(); if (theAbonents.FindByPhone(Phone).Count > 0) { string suggestedUID = String.Format(CultureInfo.InvariantCulture, "* абонент с номером {0} уже существует.", Phone); return(Json(suggestedUID, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
// // GET: /Abonents/Edit/5 public ActionResult Edit(int id) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } AbonentModel theAbonent = new AbonentModel(); BrancheModel branch = new BrancheModel(); ViewBag.AllBranches = branch.FindAll(); return(View(theAbonent.FindOne(id))); }
public void UpdateTest() { AbonentModel theAbonentNew = new AbonentModel(); theAbonentNew.Name = "TEST"; theAbonentNew.Phone = "TEST"; theAbonentNew.Description = "TEST"; AbonentModel target = new AbonentModel(); // TODO: инициализация подходящего значения target.Update(); Assert.Inconclusive("Невозможно проверить метод, не возвращающий значение."); }
public ViewResult List(int page = 1, int nOrder = 0) { AbonentModel model = new AbonentModel { Abonents = entityWork.GetAbonents(PageSize, (page - 1) * PageSize, nOrder), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = entityWork.AbonentsCount() } }; return(View(model)); }
public ActionResult Delete(int id, FormCollection collection) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } try { // TODO: Add delete logic here AbonentModel theAbonent = new AbonentModel(); theAbonent.FindOne(id); theAbonent.Delete(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View()); } }