Exemplo n.º 1
0
        public ActionResult Create(UserAvatarCreate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var avatar = this.UserAvatarService.Create();
            var privilege = new UserAvatarPrivilege();

            if (!privilege.CanCreate(avatar))
            {
                return NotAuthorized();
            }

            value.File = Request.Files[0];

            value.Validate();

            if (value.IsValid)
            {
                this.UserAvatarService.Insert(avatar, value.File);

                return base.RedirectToRoute(UsersRoutes.AvatarIndex);
            }

            value.CopyToModel(ModelState);

            return base.View(Views.Create, value);
        }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            var avatar = this.UserAvatarService.Create();
            var privilege = new UserAvatarPrivilege();

            return privilege.CanCreate(avatar) ? base.View(Views.Create, new UserAvatarCreate()) : NotAuthorized();
        }