Esempio n. 1
0
 public IActionResult AddToBasket(int id, [FromForm] int count)
 {
     logger.LogInformation($"Add good with id = {id} * count = {count}");
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     shopEngine.AddGoodToBasket(id, GetUserID(), count);
     return(RedirectToAction("Index"));
 }
Esempio n. 2
0
 public IActionResult GoodEdit(int id)
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View("Good", new GoodWorker {
         Action = "Edit", GoodModel = shopEngine.GetGoodByID(id)
     }));
 }
Esempio n. 3
0
        public IActionResult Delete(int id)
        {
            var user = GetUserID();

            logger.LogInformation($"Delete from basket for user = {user}");
            ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
            shopEngine.DeleteFromBasket(user, id);
            return(RedirectToAction("Basket", new { id = user }));
        }
Esempio n. 4
0
        public IActionResult Transaction()
        {
            int user = GetUser();

            ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
            var transaction = shopEngine.StartTransactionByBasket(user);

            return(View(new TransactionInformation
            {
                TransactionID = transaction.ActualID,
                UserID = user
            }));
        }
Esempio n. 5
0
 public IActionResult Adress(AdressModel adressModel)
 {
     if (ModelState.IsValid)
     {
         ShopEngine.ShopEngineService shopEngineService = new ShopEngine.ShopEngineService();
         var result = shopEngineService.SetAdress(adressModel);
         if (!result)
         {
             ViewBag.Error = "Incorrect adress";
             return(View(adressModel));
         }
         return(RedirectToAction("Index", "Home"));
     }
     return(View(adressModel));
 }
Esempio n. 6
0
        public IActionResult Good(GoodWorker goodWorker)
        {
            ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
            var    file = Request.Form.Files.FirstOrDefault();
            string path = string.Empty;

            if (file != null && file.Length > 0)
            {
                path = $"images\\{GetUserLogin()}\\".Replace(".", "_").Replace("@", "_");
                if (!string.IsNullOrEmpty(goodWorker.GoodModel.ImagePath))
                {
                    System.IO.File.Delete($"wwwroot\\{goodWorker.GoodModel.ImagePath}");
                }
                var realPath = $"wwwroot\\{path}";
                if (!Directory.Exists(realPath))
                {
                    Directory.CreateDirectory(realPath);
                }
                realPath += file.FileName;
                path     += file.FileName;
                if (!System.IO.File.Exists(realPath))
                {
                    using (var stream = new FileStream(realPath, FileMode.OpenOrCreate))
                        file.CopyToAsync(stream);
                }
            }

            goodWorker.GoodModel.ImagePath = path;

            switch (goodWorker.Action.ToLower())
            {
            case "new":
                shopEngine.AddGood(goodWorker.GoodModel);
                break;

            case "edit":
                shopEngine.UpdateGood(goodWorker.GoodModel);
                break;
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
 public IActionResult History()
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.DeliveryHistory(UserID)));
 }
Esempio n. 8
0
 public IActionResult Delivery([FromRoute] int id)
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     shopEngine.DeliverySuccess(id);
     return(RedirectToAction("Index", "Delivery"));
 }
Esempio n. 9
0
 public IActionResult Index()
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.DeliveryTransactions(UserID)));
 }
Esempio n. 10
0
 public IActionResult DeleteGood(int id)
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     shopEngine.DeleteGood(id);
     return(RedirectToAction("Index"));
 }
Esempio n. 11
0
 public IActionResult GoodOpen(int id)
 {
     logger.LogInformation($"Open good with id = {id}");
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.GetGoodByID(id)));
 }
Esempio n. 12
0
 public IActionResult Index()
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.GetGoodsForCreator(GetUserID())));
 }
Esempio n. 13
0
 public IActionResult Transactions()
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.Transactions(GetUserID())));
 }
Esempio n. 14
0
 public IActionResult Delivery(int id, bool success)
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     shopEngine.DeliveryUser(id, success);
     return(RedirectToAction("Transactions"));
 }
Esempio n. 15
0
 public IActionResult CancelTransaction(int id)
 {
     ShopEngine.ShopEngineService shopEngineService = new ShopEngine.ShopEngineService();
     shopEngineService.CancelTransactions(id);
     return(RedirectToAction("Transactions"));
 }
Esempio n. 16
0
 public IActionResult Basket(int id)
 {
     logger.LogInformation($"Open basket for user = {id}");
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     return(View(shopEngine.GetBaskets(id)));
 }
Esempio n. 17
0
 public IActionResult Transaction(TransactionInformation transactionModel)
 {
     ShopEngine.ShopEngineService shopEngine = new ShopEngine.ShopEngineService();
     shopEngine.TransactionInformation(transactionModel);
     return(RedirectToAction("Adress", new { id = transactionModel.TransactionID }));
 }
Esempio n. 18
0
 public IActionResult Index()
 {
     ShopEngine.ShopEngineService shopEngineService = new ShopEngine.ShopEngineService();
     return(View(shopEngineService.GetGoods()));
 }