public void UpdateInventory(ChangeInventoryModel model) { AutoInventory auto = new AutoInventory(); auto = entities.AutoInventories.Where(a => a.OutletId == model.OutletId).FirstOrDefault(); if (auto != null) { auto.IsInventory = model.IsInventory; entities.SaveChanges(); } }
//for Outlet Details #region public bool CreateOutlet(OutletModel model) { try { tblOutlet tb = new tblOutlet(); WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }); Roles.AddUserToRole(model.UserName, "Outlet"); int Id = WebSecurity.GetUserId(model.UserName); tb.Name = model.Name; tb.Active = model.Active; tb.Address = model.Address; tb.City = model.City; tb.ContactA = model.ContactA; tb.ContactB = model.ContactB; tb.Email = model.Email; tb.OutletType = "O"; //tb.Password = model.Password; tb.RegistrationDate = DateTime.Now; tb.TinNo = model.TinNo; tb.UserName = model.UserName; tb.ServiceTaxNo = model.ServiceTaxNo; tb.OutletId = Id; entities.tblOutlets.Add(tb); entities.SaveChanges(); AutoInventory auto = new AutoInventory(); auto.IsInventory = false; auto.OutletId = tb.OutletId; entities.AutoInventories.Add(auto); entities.SaveChanges(); return(true); } catch { return(false); } }