public async Task <ActionResult> New() { //Connect to db to get list of members MemberEdit memberEditView = new MemberEdit(); memberEditView.Teams = await db.Teams.ToListAsync(); return(View(memberEditView)); }
public async Task <ActionResult> Edit(int id) { //Need list of members and the current member MemberEdit memberEditView = new MemberEdit(); memberEditView.Teams = await db.Teams.ToListAsync(); memberEditView.Member = await db.Members.FindAsync(id); return(View(memberEditView)); }
public IHttpActionResult Put([FromBody] MemberEdit member) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateMemberService(); if (!service.UpdateMember(member)) { return(InternalServerError()); } return(Ok("Member updated!")); }
// GET: Member/Edit public ActionResult Edit(int id) { var service = CreateMemberService(); var detail = service.GetMemberByID(id); var model = new MemberEdit { MemberID = detail.MemberID, FirstName = detail.FirstName, LastName = detail.LastName, Location = detail.Location, FullName = $"{detail.FirstName} {detail.LastName}" }; return(View(model)); }
public bool UpdateMember(MemberEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Members.Single (e => e.MemberID == model.MemberID && e.OwnerID == _userID); { entity.MemberID = model.MemberID; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Location = model.Location; return(ctx.SaveChanges() == 1); } } }
public bool UpdateMember(MemberEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Members .Single(e => e.MemberID == model.MemberID); //entity.MemberID = model.MemberID; entity.Name = model.Name; entity.Email = model.Email; entity.Address = model.Address; entity.PhoneNumber = model.PhoneNumber; entity.CreditCardNumber = model.CreditCardNumber; entity.ExpirationDate = model.ExpirationDate; entity.SecurityCode = model.SecurityCode; entity.LocationID = model.LocationID; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, MemberEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.MemberID != id) { ModelState.AddModelError("", "Member ID's Do Not Match"); return(View(model)); } var service = CreateMemberService(); if (service.UpdateMember(model)) { TempData["SaveResult"] = "Your Profile Has Been Updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Nothing Was Changed, Please Enter Your Changes."); return(View(model)); }
private void memberEditBtn_Click(object sender, EventArgs e) { var memberForm = new MemberEdit(); Nav(memberForm, contentPanel); }