示例#1
0
        public IActionResult LicenceView(int id)
        {
            ViewLicenceViewModel model = null;
            Licence licence            = _licenceProvider.LicencesGet(UserId()).Where(l => l.Id == id).FirstOrDefault();

            if (licence != null)
            {
                model = new ViewLicenceViewModel(licence.Id, licence.DomainName, licence.LicenceType.Description,
                                                 Shared.Utilities.DateWithin(licence.ExpireDate, licence.StartDate, DateTime.Now) && licence.IsValid,
                                                 licence.IsTrial, licence.ExpireDate, licence.UpdateCount, licence.EncryptedLicence);
            }

            if (model == null)
            {
                RedirectToAction(nameof(Licences));
            }

            return(View(model));
        }
示例#2
0
        public IActionResult LicenceUpdateDomain(ViewLicenceViewModel model)
        {
            Licence licence = _licenceProvider.LicencesGet(UserId()).Where(l => l.Id == model.Id).FirstOrDefault();

            if (!Shared.Utilities.ValidateIPAddress(model.Domain))
            {
                ModelState.AddModelError(nameof(model.Domain), "Invalid ip address");
                return(View(nameof(LicenceView), model));
            }

            if (licence != null)
            {
                if (_licenceProvider.LicenceUpdateDomain(UserId(), licence, model.Domain))
                {
                    GrowlAdd("Licence updated");
                    return(RedirectToAction(nameof(Licences)));
                }
            }

            GrowlAdd("Failed to update licence");
            return(RedirectToAction(nameof(Licences)));
        }