public IActionResult EditName(string artistName, int artistlId) { var model = new MyAccountViewModel(); var artist = _artistManager.GetOne(x => x.Id == artistlId, includeProperties: $"{ nameof(Artist.User)}"); if (string.IsNullOrWhiteSpace(artistName)) { ModelState.AddModelError("Name", "The Name must contain at least 2 characters"); return(View("MyAccount", model)); } artistName = artistName.Trim(); if (artistName.Length < 2) { ModelState.AddModelError("Name", "The Name must contain at least 2 characters"); return(View("MyAccount", model)); } if (artistName.Length > 50) { ModelState.AddModelError("Name", "The Name cannot contain more than 50 characters"); return(View("MyAccount", model)); } artist.User.Name = artistName; _artistManager.Update(artist, artistlId); _artistManager.Save(); return(RedirectToAction("MyAccount")); }
public IActionResult AddNewArtist(InviteViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var recordLabel = _recordLabelManager.GetOne(filter: x => x.Id == CurrentLoggedUserId, includeProperties: $"{nameof(User)}"); if (recordLabel == null) { return(View(model)); } if (_recordLabelManager.GetNumberOfArtists(CurrentLoggedUserId) >= MBoxConstants.MaximumArtistsAllowed) { ModelState.AddModelError("Email", "Artist limit (50) reached. Cannot add new artist."); return(View(model)); } var response = _userManager.CreateUser(model.Name, model.Email, Role.Artist); if (response == null) { ModelState.AddModelError("EMail", "Email already exists"); return(View(model)); } var user = response.Result; _artistsManager.Create(new Artist { User = user, RecordLabelArtists = new List <RecordLabelArtist> { new RecordLabelArtist { RecordLabel = recordLabel } } }, CurrentLoggedUserId); _artistsManager.Save(); var code = _userManager.GeneratePasswordResetTokenAsync(user).Result; var callbackUrl = Url.ResetPasswordCallbackLink(user.Id.ToString(), code, Request.Scheme); _emailsManager.PrepareSendMail(EmailTemplateType.InvitedArtist, model.Email, callbackUrl); return(View("SuccessfullyInvitedArtist")); }