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 })); }
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()); }
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)); }
public async Task <IActionResult> SetCurrentAvatar(IFormFile postedImage) { var user = await CurrentUser; return(await _avatar.SetAvatarResult(user, postedImage)); }