예제 #1
0
        public IActionResult CreateTopping(CreateToppingViewModel newItem)
        {
            var newCreatedItem = new Topping
            {
                Active      = newItem.Active == "true" ? true : false,
                ToppingName = newItem.Name,
                CreateBy    = 1,
                CreateTime  = DateTime.UtcNow,
                UpdateBy    = 1,
                UpdateTime  = DateTime.UtcNow
            };

            _ctx.Topping.Add(newCreatedItem);
            _ctx.SaveChanges();

            foreach (var toppingTypeId in newItem.ToppingTypeIds)
            {
                var toppingSysRef = new ToppingSystemReference
                {
                    ToppingId     = newCreatedItem.Id,
                    ToppingTypeId = toppingTypeId,
                    CreateBy      = 1,
                    CreateTime    = DateTime.UtcNow,
                    UpdateBy      = 1,
                    UpdateTime    = DateTime.UtcNow
                };
                _ctx.ToppingSystemReference.Add(toppingSysRef);
            }
            _ctx.SaveChanges();
            var success = newItem.Name.ToString();

            ViewBag.Create = success;
            return(Redirect("CreateTopping"));
        }
예제 #2
0
        public IActionResult CreateTopping()
        {
            var toppingTypes = _ctx.SystemReference.Where(x => x.AltValue == "Topping").ToList();

            var toppingTypesViewModel = new CreateToppingViewModel
            {
                ToppingTypes = toppingTypes
            };

            return(View(toppingTypesViewModel));
        }