Пример #1
0
        public ActionResult Stores()
        {
            if (!IsAdmin())
            {
                return(Redirect("/"));
            }
            NewStoreVM ns = new NewStoreVM();

            ns.AllStores = _storeService.GetAll();
            return(View(ns));
        }
Пример #2
0
        public ActionResult EditS(Guid id)
        {
            if (!IsAdmin())
            {
                return(Redirect("/"));
            }
            NewStoreVM ni = new NewStoreVM();

            ni.AllStores = _storeService.GetAll();
            ni.Store     = _storeMapper.ConvertToStoreVM(_storeService.FindById(id), null);
            return(View("Stores", ni));
        }
Пример #3
0
        public ActionResult Store(Guid id)
        {
            if (!IsAdmin())
            {
                return(Redirect("/"));
            }
            Store      s  = _storeService.FindById(id);
            NewStoreVM ns = new NewStoreVM();

            ns.ItemToAdd = new ItemVM();
            ns.Store     = _storeMapper.FindItemsForStore(s);
            return(View(ns));
        }
Пример #4
0
 private bool Validate(NewStoreVM ns)
 {
     if (ns.ItemToAdd == null || ns.ItemToAdd.Id.Equals(new Guid()))
     {
         return(false);
     }
     if (ns.Store == null || ns.Store.Id.Equals(new Guid()))
     {
         return(false);
     }
     if (ns.ItemToAdd.SelectedAverableSize == null || ns.ItemToAdd.SelectedAverableSize.Size <= 0)
     {
         return(false);
     }
     return(true);
 }
Пример #5
0
 public ActionResult Store(NewStoreVM ns)
 {
     if (!IsAdmin())
     {
         return(Redirect("/"));
     }
     if (Request.Form["add"] != null)
     {
         //Add form
         if (Validate(ns))
         {
             StoreItem si = new StoreItem();
             si.ItemId  = ns.ItemToAdd.Id;
             si.StoreId = ns.Store.Id;
             si.Price   = ns.ItemToAdd.Price;
             si         = _siService.Add(si);
             AvailableSize ass = new AvailableSize();
             ass.SIId = si.Id;
             ass.Size = ns.ItemToAdd.SelectedAverableSize.Size;
             _asService.Add(ass);
             return(Redirect("/Admin/Store/" + ns.Store.Id.ToString()));
         }
     }
     else if (Request.Form["remove"] != null)
     {
         if (Validate(ns))
         {
             //remove size from item
             StoreItem si = _siService.FindByStoreIdAndItemId(ns.Store.Id, ns.ItemToAdd.Id);
             if (si != null)
             {
                 _asService.RemoveBySIIdAndSize(si.Id, ns.ItemToAdd.SelectedAverableSize.Size);
                 return(Redirect("/Admin/Store/" + ns.Store.Id.ToString()));
             }
         }
     }
     return(Redirect("/Admin/Store/" + ns.Store.Id.ToString()));
 }