public ActionResult AddSales(Transactions transactions) { Transactions trans = new Transactions { UserID = Convert.ToInt32(Session["UserID"]), ProductID = transactions.ProductID, Quantity = transactions.Quantity, ProductDetail = transactions.ProductDetail, TransactionDate = transactions.TransactionDate, //TransactionID = transactions.TransactionID }; transactions = trans; if (Session["EmailID"] == null) { return(Redirect("~/Login/Login")); } else { if (!ModelState.IsValid) { db.Transactions.Add(transactions); db.SaveChanges(); ModelState.Clear(); //ViewBag.Message = "Sale is successfully added."; //return View(); } return(RedirectToAction("AddSales")); } }
public ActionResult Category(Category productCategory) { try { if (Session["EmailID"] == null) { return(Redirect("~/Login/Login")); } else { if (ModelState.IsValid) { db.Categories.Add(productCategory); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Category is successfully created."; return(View()); } return(View()); } } catch (Exception) { throw; } }
public ActionResult Register(User user) { try { if (ModelState.IsValid) { Ad_insightContext db = new Ad_insightContext(); var userRecord = db.Users.Where(a => a.EmailID == user.EmailID).FirstOrDefault(); if (userRecord != null) { if (userRecord.EmailID == user.EmailID) { ViewBag.Error = "User already exist"; ModelState.Clear(); return(View()); } } else { db.Users.Add(user); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Successfully Registered"; return(View()); } } return(View()); } catch (Exception) { throw; } }