//GET: Admin/EditDetails/5 public async Task <IActionResult> EditDetails(int id) { EditPracticeViewModel practice = await _practicesService.GetEditPracticeViewModel(id); if (practice == null) { return(NotFound()); } return(Json(practice)); }
public async Task <JsonResponse> UpdatePractice(EditPracticeViewModel editPracticeViewModel) { var dbPractice = await _context.Practices.Where(p => p.Id == editPracticeViewModel.Id).SingleOrDefaultAsync(); if (dbPractice == null) { return(new JsonResponse(false, "Practice not found.")); } dbPractice.UpdateProperties(editPracticeViewModel); await _context.SaveChangesAsync(); return(new JsonResponse() { Success = true }); }
public async Task <IActionResult> SaveDetails([FromBody] EditPracticeViewModel editPracticeViewModel) { if (editPracticeViewModel == null) { return(Json(new JsonResponse(false, "Server did not receive data."))); } if (string.IsNullOrEmpty(editPracticeViewModel.Name)) { return(Json(new JsonResponse(false, "Name is not set."))); } try { return(Json(await _practicesService.UpdatePractice(editPracticeViewModel))); } catch (DbUpdateConcurrencyException) { return(Json(new JsonResponse(false, "Concurrency error."))); } }