Exemplo n.º 1
0
        //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));
        }
Exemplo n.º 2
0
        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
            });
        }
Exemplo n.º 3
0
        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.")));
            }
        }