コード例 #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());
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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
ファイル: StoreService.cs プロジェクト: okicks/Foda
        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);
        }