public ActionResult SaveCategory(string categoryname) { DATA.Domains.Category category = new DATA.Domains.Category { Name = categoryname, TradeMarkId = 1 }; productprovider.SaveCategory(category); return(RedirectToAction("AddProduct")); }
public void SaveCategory(DATA.Domains.Category category) { using (BmsDbContext context = new BmsDbContext()) { var validate = context.Category.Where(name => name.Name == category.Name).FirstOrDefault(); if (validate == null) { context.Category.Add(category); context.SaveChanges(); } } }