public ActionResult Index([FromBody] TalentPersonalDataEditVM modelVM) { try { var curUser = accountUtil.GetCurrentUser(User); Talent model = TalentService.GetByID(modelVM.id); if (model == null || !model.UserID.Equals(curUser.ID)) { throw new Exception("Талант не найден"); } if (ModelState.IsValid) { model.FullName = modelVM.full_name; //model.FirstName = modelVM.FirstName; //model.LastName = modelVM.LastName; model.Bio = modelVM.bio; model.SocialAreaID = modelVM.social_area_id; model.SocialAreaHandle = modelVM.social_area_handle; model.FollowersCount = modelVM.followers_count; TalentService.TransliterateFullname(model); TalentService.Update(model, curUser.ID); return(Ok()); } else { throw new Exception("Указаны некорректные данные"); } } catch (Exception ex) { return(CustomBadRequest(ex)); } }
public ActionResult <TalentPersonalDataEditVM> Index() { try { var curUser = accountUtil.GetCurrentUser(User); Talent model = TalentService.GetByUserID(curUser.ID); if (model == null) { throw new Exception("Талант не найден"); } if (model.AvatarID.HasValue) { model.Avatar = AttachmentService.GetByID(model.AvatarID.Value); } TalentPersonalDataEditVM modelVM = new TalentPersonalDataEditVM(model); return(Ok(modelVM)); } catch (Exception ex) { return(CustomBadRequest(ex)); } }