public ActionResult Create([Bind(Prefix = "")] Models.SoftwareLicenses model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { if (db.Software_Licenses.Count() > 0) { var item = db.Software_Licenses.OrderByDescending(a => a.LicenceID).FirstOrDefault(); db.Software_Licenses.Add(new CodeFirst.Software_Licenses { LicenceID = item.LicenceID + 1, SoftwareName = model.SoftwareName, ActivationPeriodInMonths = model.ActivationPeriodInMonths }); } else { db.Software_Licenses.Add(new CodeFirst.Software_Licenses { LicenceID = 1, SoftwareName = model.SoftwareName, ActivationPeriodInMonths = model.ActivationPeriodInMonths }); } db.SaveChanges(); model.JavaScriptToRun = "mySuccess()"; TempData["model"] = model; return(RedirectToAction("Index", "SoftwareLicenses")); } return(View("Index", model)); }
// GET: AddSoftwareLicenses public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var SoftwareLic = new Models.SoftwareLicenses(); return(View(SoftwareLic)); }
// GET: SoftwareLicenses public ActionResult Index() { Models.SoftwareLicenses myModel = new Models.SoftwareLicenses(); if (TempData["model"] != null) { myModel = (Models.SoftwareLicenses)TempData["model"]; TempData.Remove("model"); } return(View(myModel)); }
// GET: SoftwareLicensesDetails public ActionResult Index(string licenceID) { Models.SoftwareLicenses myModel = new Models.SoftwareLicenses(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (licenceID != null) { var intLicID = Int32.Parse(licenceID); var myLicence = db.Software_Licenses.Where(i => i.LicenceID == intLicID).FirstOrDefault(); myModel.LicenceID = myLicence.LicenceID; myModel.SoftwareName = myLicence.SoftwareName; myModel.ActivationPeriodInMonths = myLicence.ActivationPeriodInMonths; } return(View(myModel)); }
public ActionResult Index(Models.SoftwareLicenses model) { CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { Models.SoftwareLicenses myModel = new Models.SoftwareLicenses(); var myLicence = db.Software_Licenses.Where(i => i.LicenceID == model.LicenceID).FirstOrDefault(); myModel.LicenceID = myLicence.LicenceID; myModel.SoftwareName = myLicence.SoftwareName; myModel.ActivationPeriodInMonths = myLicence.ActivationPeriodInMonths; return(View(myModel)); } return(View(model)); }
public ActionResult Modify([Bind(Prefix = "")] Models.SoftwareLicenses model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var Licence = db.Software_Licenses.Where(v => v.LicenceID == model.LicenceID).SingleOrDefault(); if (Licence != null) { Licence.LicenceID = model.LicenceID; Licence.SoftwareName = model.SoftwareName; Licence.ActivationPeriodInMonths = model.ActivationPeriodInMonths; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "SoftwareLicenses")); } return(View("Index", model)); }