Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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("Невозможно проверить метод, не возвращающий значение.");
        }