Beispiel #1
0
        public async Task <ActionResult> FillInventory(Inventory inventory)
        {
            using (var context = new Farmazon_dbEntities())
            {
                var userId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

                context.CreateInventoryItem(userId, inventory.Quantity, inventory.Price, inventory.ProductName, inventory.PhotoLocation, inventory.Description, inventory.ReviewCount, inventory.ReviewStars);
                await context.SaveChangesAsync();

                return(new HttpStatusCodeResult((int)HttpStatusCode.OK));
            }
        }
Beispiel #2
0
        public async Task <ActionResult> FillInventory(Inventory inventory)
        {
            if (ModelState.IsValid)
            {
                using (var context = new Farmazon_dbEntities())
                {
                    var userId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

                    context.CreateInventoryItem(userId, inventory.Quantity, inventory.Price, inventory.ProductName, inventory.PhotoLocation, inventory.Description, inventory.ReviewCount, inventory.ReviewStars);
                    await context.SaveChangesAsync();

                    return(RedirectToAction("GetInventory", "Account"));
                }
            }
            return(View(inventory));
        }
Beispiel #3
0
        public async Task <ActionResult> CreateFarm(Farm farmModel)
        {
            if (ModelState.IsValid)
            {
                using (var context = new Farmazon_dbEntities())
                {
                    var userId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

                    context.CreateFarm(farmModel.FarmName, userId, farmModel.Description, farmModel.Location);
                    await context.SaveChangesAsync();

                    return(RedirectToAction("Getfarm"));
                }
            }
            return(View(farmModel));
        }