public async Task <IActionResult> Put(int id, [FromBody] AppointUpt model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != model.Id) { return(BadRequest()); } try { var user = await GetCurrentUser(); model.UserId = user.Id; model.ModifiedBy = user.UserName; _svc.Put(id, model); } catch (System.Exception ex) { return(StatusCode(420, ex)); } return(Ok()); }
public IActionResult CustomerEdit([FromRoute] int id, CustomerEditModel model) { try { if (ModelState.IsValid) { //build model AppointUpt uptmodel = new AppointUpt(); uptmodel.Id = model.Id; uptmodel.UserId = model.UserId; uptmodel.CustFName = model.CustFName; uptmodel.CustLName = model.CustLName; uptmodel.Street = model.Street; uptmodel.City = model.City; uptmodel.State = model.State.ToUpper(); uptmodel.Zip = model.Zip; uptmodel.Email = model.Email; uptmodel.Phone = model.Phone; DateTime newDate = DateTime.Parse(model.AppointDate + "T" + model.AppointTime); uptmodel.Appoint = newDate; uptmodel.ModifiedBy = model.CustFName + " " + model.CustLName; uptmodel.IsCnfrmed = model.IsCnfrmed; uptmodel.ReminderSent = model.ReminderSent; uptmodel.CompName = model.CompName; uptmodel.CompEmail = model.CompEmail; _svc.Put(id, uptmodel); return(RedirectToAction("DoneEdit", "Account")); } else { return(BadRequest(ModelState)); } } catch (Exception ex) { return(StatusCode(420, ex)); } }