public IActionResult SaveAuthorProfile(AuthorProfileModel model) { if (JMSUser.IsDisabled.GetValueOrDefault()) { return(Unauthorized()); } if (ModelState.IsValid) { var userId = long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); _userService.SaveAuthor(new JMS.ViewModels.Users.AuthorProfileModel { City = model.City, Country = model.Country, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, State = model.State, UserId = userId, Zip = model.Zip, ORCID = model.ORCID, AffiliationNo = model.AffiliationNo }, model.ProfileImageFile?.OpenReadStream(), model.ProfileImageFile?.FileName); TempData.Add(Messages.SuccessProfileMessage, Messages.SuccessProfileMessage); return(RedirectToAction("ViewProfile")); } return(View("ViewProfile", model)); }
public void SaveAuthor(AuthorProfileModel authorProfileModel, Stream fileStream, string fileName) { var author = _context.Authors.Single(x => x.Id == authorProfileModel.UserId); author.Orcid = authorProfileModel.ORCID; using (var tr = _context.Database.BeginTransaction()) { try { SaveSystemAdmin(authorProfileModel, fileStream, fileName); tr.Commit(); } catch (Exception ex) { tr.Rollback(); throw; } } }