Пример #1
0
        public ActionResult Create([Bind(Include = "Id, Employee, Month, Department, SubscriptionType, Amount, Notes, IsFixed")] Subscription subscription)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    SubscriptionServices.Insert(CurrentUser.Id, subscription, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.DepartmentList       = new SelectList(DepartmentServices.List(db), "Id", "Name");
            ViewBag.EmployeeList         = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            ViewBag.SubscriptionTypeList = new SelectList(SubscriptionTypeServices.List(db), "Id", "Name");
            return(View(subscription));
        }
Пример #2
0
        public void TestInsertMustCallRepository()
        {
            var data = Builder <SubscriptionDTO> .CreateNew().Build();

            target.Insert(data);

            _subscriptionRepositoryMock.Verify(m => m.Insert(It.IsAny <SubscriptionModel>()), Times.Once);
        }