示例#1
0
        public ActionResult Create(StoreCreate model)
        {
            if (IsAdmin())
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var service = CreateService();

                if (service == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                if (service.CreateStore(model))
                {
                    TempData["SaveResult"] = "Your Store was created.";
                    return(RedirectToAction("Index"));
                }
                ;

                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
示例#2
0
        public IActionResult CreateStore()
        {
            var model = new StoreCreate();

            model.Locations = WarehouseService.GetLocations(UserID);

            return(View(model));
        }
示例#3
0
        public IActionResult CreateStore(StoreCreate store)
        {
            if (WarehouseService.CreateStore(store, UserID))
            {
                return(RedirectToAction("Index"));
            }

            return(View(store));
        }
示例#4
0
        /// <summary>
        /// Creates a new Store
        /// </summary>
        /// <param name="store"></param>
        /// <returns></returns>

        public IHttpActionResult Post(StoreCreate store)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateStoreService();

            if (!service.CreateStore(store))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
        public bool CreateStore(StoreCreate model)
        {
            var entity = new Store()
            {
                OwnerId     = _userId,
                Name        = model.Name,
                Location    = model.Location,
                TypeofStore = model.TypeOfStore
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Stores.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(StoreCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateStoreService();

            if (service.CreateStore(model))
            {
                TempData["SaveResult"] = "Your store was built.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Store could not be built.");
            return(View(model));
        }
示例#7
0
        public bool CreateStore(StoreCreate model)
        {
            var entity =
                new Store()
            {
                OwnerId     = _userId,
                StoreId     = model.StoreId,
                StoreName   = model.StoreName,
                Address     = model.Address,
                StoreRating = model.StoreRating
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Stores.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#8
0
        public bool CreateStore(StoreCreate model)
        {
            var entity = new Store()
            {
                StoreId          = model.StoreId,
                StoreName        = model.StoreName,
                StoreStreet      = model.StoreStreet,
                StoreCity        = model.StoreCity,
                StoreState       = model.StoreState,
                StoreZip         = model.StoreZip,
                StorePhoneNumber = model.StorePhoneNumber,
                OwnerId          = _userId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Stores.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#9
0
        public bool CreateStore(StoreCreate newStore, int userID)
        {
            bool success;

            try
            {
                var store = newStore.Adapt <tbl_Stores>();
                store.CreatedDate = DateTime.Now;
                store.UserID      = userID;

                db.SaveStore(store);
                CurrentUser.UpdateLocations(userID);
                success = true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return(success);
        }