Пример #1
0
        public void TestUpdateGood()
        {
            var odmen      = new OdmenAction();
            var store      = new StoreAction();
            var goodUpdate = store.GetAllGoods().FirstOrDefault(s => s.name.Contains("name"));

            if (goodUpdate == null)
            {
                Assert.Pass("Нет тестового товара для изменения");
                return;
            }
            goodUpdate.name     = "name_Updated";
            goodUpdate.info     = "info_Updated";
            goodUpdate.imageUrl = "imageUrl_Updated";
            goodUpdate.discount = 78;
            goodUpdate.price    = 67889.23M;
            goodUpdate.groupId  = store.GetGroups().Last().id;
            goodUpdate.fullInfo = "fullInfo_Updated";
            odmen.ChangeGood(goodUpdate);
            var updated = store.GetAllGoods().FirstOrDefault(s => s.name == goodUpdate.name
                                                             //&& s.fullInfo == goodUpdate.fullInfo
                                                             && s.info == goodUpdate.info && s.imageUrl == goodUpdate.imageUrl &&
                                                             s.price == goodUpdate.price && s.discount == goodUpdate.discount);

            // TODO: Add your test code here
            Assert.IsNotNull(updated);
        }
Пример #2
0
        public JsonResult CreateEditGood(Good model)
        {
            if (model.isEdit && model.id == 0)
            {
                throw new Exception("Попытка редактирования товара у которого не задан Id");
            }
            var admin = new OdmenAction();

            if (model.isEdit)
            {
                admin.ChangeGood(model);
            }
            else
            {
                admin.CreateGood(model);
            }
            return(Json(new { result = 0 }, JsonRequestBehavior.AllowGet));
        }