Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        // 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));
 }
Exemplo n.º 4
0
        // 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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }