コード例 #1
0
        public async Task <IActionResult> CreateOrg(Organization org, [FromForm(Name = "Avatar")] IFormFile avatar)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", org));
            }

            _context.Organizations.Add(org);
            await _context.SaveChangesAsync();

            if (avatar != null)
            {
                await _avatar.SetAvatarResult(org, avatar);
            }

            return(RedirectToAction("Details", new { id = org.Id }));
        }
コード例 #2
0
ファイル: ProjectController.cs プロジェクト: adam8797/WePrint
        public async Task <IActionResult> SetAvatar(Guid id, IFormFile postedImage)
        {
            var project = await Database.Projects.FindAsync(id);

            if (await _permission.AllowWrite(await CurrentUser, project))
            {
                return(await _avatar.SetAvatarResult(project, postedImage));
            }

            return(Forbid());
        }
コード例 #3
0
        public async Task <IActionResult> SetOrgAvatar(Guid id, IFormFile upload)
        {
            var org = await Database.Organizations.FindAsync(id);

            if (org == null)
            {
                return(NotFound());
            }

            if (!await Permissions.AllowWrite(await CurrentUser, org))
            {
                return(Forbid());
            }

            return(await _avatar.SetAvatarResult(org, upload));
        }
コード例 #4
0
ファイル: UserController.cs プロジェクト: adam8797/WePrint
        public async Task <IActionResult> SetCurrentAvatar(IFormFile postedImage)
        {
            var user = await CurrentUser;

            return(await _avatar.SetAvatarResult(user, postedImage));
        }