public void AddShop()
        {
            var oldShop = new Common.Shop()
            {
                NameShop        = "Lime",
                Address         = "Зарубина",
                DescriptionShop = "Кафе",
                Website         = "lime.ru",
                Rating          = 0,
                PhoneShop       = "+7909323232",
                City            = "Saratov",
                OpeningHours    = "9:00-21:00"
            };

            int id = logic.AddShop(oldShop);

            var shop = logic.GetShopById(id);

            Assert.IsNotNull(shop, "Shop is null");
            Assert.AreEqual(Common.Shop.ToString(oldShop), Common.Shop.ToString(shop), "Не совпали названия магазинов при добавлении");
        }
        public ActionResult Create(ShopCreateVM shop, HttpPostedFileBase uploadFile)
        {
            try
            {
                if (uploadFile != null)
                {
                    if (uploadFile.ContentLength > 0)
                    {
                        if (Path.GetExtension(uploadFile.FileName).ToLower() == ".jpg" ||
                            Path.GetExtension(uploadFile.FileName).ToLower() == ".png" ||
                            Path.GetExtension(uploadFile.FileName).ToLower() == ".gif" ||
                            Path.GetExtension(uploadFile.FileName).ToLower() == ".jpeg")
                        {
                            HttpPostedFileBase uploadFileCopy = uploadFile;
                            string             ImageName      = System.IO.Path.GetFileName(uploadFileCopy.FileName); //file2 to store path and url
                            string             physicalPath   = Server.MapPath("~/img/" + ImageName);
                            // save image in folder
                            uploadFileCopy.SaveAs(physicalPath);
                            byte[] mas = new byte[uploadFile.ContentLength];
                            uploadFile.InputStream.Read(mas, 0, uploadFile.ContentLength);
                            shop.Image = mas;
                        }
                    }
                }
                if (ModelState.IsValid)
                {
                    shop.Moderator = (_userLogic.GetUserByEMail(System.Web.HttpContext.Current.User.Identity.Name.ToString()) ?? new Common.User()).IDUser;

                    _shopLogic.AddShop(Mapper.Map <ShopCreateVM, Shop>(shop));
                    return(RedirectToAction("IndexForModerator"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(String.Empty, ex);
            }
            return(View(shop));
        }
Beispiel #3
0
 //Shop
 public void AddShop(ShopVM shop)
 {
     _shopLogic.AddShop(shop.NameShop, shop.IdTypeOfShop, shop.IdAddress, out var alert);
 }