public bool CommodityStallSave(CommodityStallCreateModel commodityStallCreateModel)
        {
            if (commodityStallCreateModel.CommodityID != null)
            {
                if (commodityStallCreateModel != null)
                {
                    using (var context = new ShukRoutingContext())
                    {
                        var commoditystall = new CommodityStall()
                        {
                            CommodityID    = commodityStallCreateModel.CommodityID,
                            StallID        = commodityStallCreateModel.StallID,
                            Price          = commodityStallCreateModel.Price,
                            Rating         = commodityStallCreateModel.Rating,
                            TimeRegistered = DateTime.Now,
                            Notes          = commodityStallCreateModel.Notes
                        };
                        commoditystall.Commodity = context.Commodities.Find(commodityStallCreateModel.CommodityID);
                        commoditystall.Stall     = context.Stalls.Find(commodityStallCreateModel.StallID);

                        context.CommoditiesStalls.Add(commoditystall);
                        context.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public ActionResult Create()
        {
            var repo = new CommodityStallRepository();
            CommodityStallCreateModel result = repo.CreateCommStall();

            return(View(result));
        }
        public CommodityStallCreateModel CreateCommStall()
        {
            var stallRepo     = new StallRepository();
            var commodityRepo = new CommodityRepository();

            var commStallModel = new CommodityStallCreateModel()
            {
                CommodityNames = commodityRepo.GetCommoditiesNames(),
                StallNames     = stallRepo.GetStallNames(),
            };

            return(commStallModel);
        }
Example #4
0
        public ActionResult Create([Bind(Include = "CommodityStallID, CommodityID, StallID, Price, Rating, TimeRegistered, Notes")] CommodityStallCreateModel model)
        {
            var  repo  = new CommodityStallRepository();
            bool saved = repo.CommodityStallSave(model);

            if (saved)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var stallrepository = new StallRepository();

            model.StallNames = stallrepository.GetStallNames();

            return(View(model));
        }