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); } }
public bool SaveNewCommodity(CommodityModel commodity) { if (commodity != null) { using (var context = new ShukRoutingContext()) { Commodity Commodity = new Commodity() { CommodityID = commodity.CommodityID, CommodityName = commodity.CommodityName }; context.Commodities.Add(Commodity); context.SaveChanges(); } return(true); } return(false); }
public bool SaveNewStall(StallModel stall) { if (stall != null) // maybe take out { using (var context = new ShukRoutingContext()) { var Stall = new Stall() { StallID = stall.StallID, StallName = stall.StallName, FirstCoord = stall.FirstCoord, SecondCoord = stall.SecondCoord }; context.Stalls.Add(Stall); context.SaveChanges(); } return(true); } return(false); }