public bool UpdateBio(BioEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Bios .Single(e => e.BioId == model.BioId && e.OwnerId == _userId); entity.FullName = model.FullName; entity.NickNames = model.NickNames; entity.Birthday = model.Birthday; entity.Age = model.Age; entity.Gender = model.Gender; entity.Location = model.Location; entity.Race = model.Race; entity.Ethnicity = model.Ethnicity; entity.AboutYou = model.AboutYou; entity.Interests = model.Interests; entity.Hobbies = model.Hobbies; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public async Task <ActionResponse> UpdateBio([FromBody] BioEdit bioRequest) { string userId = authenticationCurrentContext.CurrentUser; bool updated = await userRepository.UpdateBio(userId, bioRequest.Bio, bioRequest.JobTitle, bioRequest.Strengths); return(new ActionResponse { State = updated }); }
public ActionResult Edit(int id, BioEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.BioId != id) { ModelState.AddModelError("", "Id mismatch"); return(View(model)); } var service = CreateBioService(); if (service.UpdateBio(model)) { TempData["SaveResult"] = "Your bio was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your bio could not be updated."); return(View(model)); }
public ActionResult Edit(int id) { var service = CreateBioService(); var detail = service.GetBioById(id); var model = new BioEdit { BioId = detail.BioId, FullName = detail.FullName, NickNames = detail.NickNames, Birthday = detail.Birthday, Age = detail.Age, Gender = detail.Gender, Location = detail.Location, Race = detail.Race, Ethnicity = detail.Ethnicity, AboutYou = detail.AboutYou, Interests = detail.Interests, Hobbies = detail.Hobbies, }; return(View(model)); }