Ejemplo n.º 1
0
        public ActionResult Update(CountryCreateOrUpdate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var country = this.CountryService.GetById(value.Id);

            if (country == null)
            {
                return HttpNotFound();
            }

            var privilege = new CountryPrivilege();

            if (!privilege.CanUpdate(country))
            {
                return NotAuthorized();
            }

            value.Validate();

            if (value.IsValid)
            {
                value.ValueToModel(country);

                this.CountryService.InsertOrUpdate(country);

                value.SuccessMessage(Messages.CountryUpdated.FormatInvariant(country.Title));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

            return base.View(Views.Update, value);
        }
Ejemplo n.º 2
0
        public ActionResult Update(int id)
        {
            var country = this.CountryService.GetById(id);

            if (country == null)
            {
                return HttpNotFound();
            }

            var privilege = new CountryPrivilege();

            return privilege.CanUpdate(country) ? base.View(Views.Update, new CountryCreateOrUpdate(country)) : NotAuthorized();
        }