Exemple #1
0
        //[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
        public async Task <IActionResult> Details(MedicalCoverDetailViewModel formData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _medicalCoverServices.UpdateMedicalCoverAsync(new MedicalCover
                    {
                        DateTimeModified = DateTimeOffset.Now,
                        Title            = formData.Title,
                        Id          = formData.Id,
                        UserAccount = User.Identity.Name
                    });

                    TempData["Message"] = "Changes saved successfully";
                    _logger.LogInformation($"Success: successfully updated {formData.Title} Medical record by user={@User.Identity.Name.Substring(4)}");
                    return(RedirectToAction("details", new { id = formData.Id }));
                }
            }
            catch (ApplicationException error)
            {
                ModelState.AddModelError("Medical", $"Failed to update record. {formData.Title} Contact IT ServiceDesk for support.");
                _logger.LogError(
                    error,
                    $"FAIL: failed to update {formData.Title} MedicalCover. Internal Application Error.; user={@User.Identity.Name.Substring(4)}");
            }

            return(View(formData));
        }
Exemple #2
0
        //[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
        public async Task <IActionResult> Details(Guid id)
        {
            var medicalQuery = await _medicalCoverServices.GetMedicalCoverById(id);

            if (medicalQuery == null)
            {
                return(NotFound());
            }

            var model = new MedicalCoverDetailViewModel
            {
                Title = medicalQuery.Title,
                Id    = medicalQuery.Id,
            };

            return(View(model));
        }