Exemplo n.º 1
0
        public async Task <IActionResult> Details(RepatriationDetailViewModel formData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _repatriationServices.UpdateRepatriationAsync(new EmployeeRepatriation
                    {
                        DateTimeModified = DateTimeOffset.Now,
                        EmployeeId       = formData.EmployeeId,
                        Name             = formData.Name,
                        RelationshipId   = formData.RelationshipId,
                        UserAccount      = User.Identity.Name,
                        Id = formData.Id
                    });

                    TempData["Message"] = "Changes saved successfully";
                    _logger.LogInformation($"Success: successfully updated employee repatriation 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 repatriation details {formData.Name}. Internal Application Error.; user={@User.Identity.Name.Substring(4)}");
                ModelState.AddModelError("Repatriation", $"Failed to update employee repatriation record. {formData.Name} Contact IT ServiceDesk for support thank you.");
            }
            await LoadSelectListsAsync();

            return(View(formData));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Details(Guid id)
        {
            var repatriationQuery = await _repatriationServices.GetRepatriationById(id);

            if (repatriationQuery == null)
            {
                return(NotFound());
            }
            var model = new RepatriationDetailViewModel
            {
                Id             = repatriationQuery.Id,
                EmployeeId     = repatriationQuery.EmployeeId ?? Guid.Empty,
                Name           = repatriationQuery.Name,
                RelationshipId = repatriationQuery.RelationshipId
            };

            await LoadSelectListsAsync();

            return(View(model));
        }