Beispiel #1
0
        public async Task <IActionResult> Details(DisplinaryDetailsViewModel formData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _displinaryServices.UpdateDisplinaryAsync(new Displinary
                    {
                        DateTimeModified = DateTimeOffset.Now,
                        EmployeeID       = formData.Employee,
                        CrimeDescription = formData.CrimeDescription,
                        ConvictionDate   = DateTime.Parse(formData.ConvictionDate),
                        ConvictionPlace  = formData.ConvictionPlace,
                        IsConvicted      = formData.IsConvicted,
                        SentenceImposed  = formData.SentenceImposed,
                        UserAccount      = User.Identity.Name,
                        Id = formData.Id
                    });

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

            return(View(formData));
        }
Beispiel #2
0
        public async Task <IActionResult> Details(Guid id)
        {
            var misconductQuery = await _displinaryServices.GetDisplinaryRecordById(id);

            if (misconductQuery == null)
            {
                return(NotFound());
            }
            var model = new DisplinaryDetailsViewModel
            {
                Id               = misconductQuery.Id,
                Employee         = misconductQuery.EmployeeID ?? Guid.Empty,
                ConvictionPlace  = misconductQuery.ConvictionPlace,
                IsConvicted      = misconductQuery.IsConvicted,
                SentenceImposed  = misconductQuery.SentenceImposed,
                CrimeDescription = misconductQuery.CrimeDescription,
                ConvictionDate   = misconductQuery.ConvictionDate == null ? string.Empty : DateTime.Parse(misconductQuery.ConvictionDate.ToString()).ToString("yyyy-MM-dd")
            };

            await LoadSelectListsAsync();

            return(View(model));
        }