public async Task <IActionResult> Add(NewRelationshipViewModel formData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool bIfExist = false;
                    var  q        = from c in _db.RelationShipTypes where c.Title == formData.Title select c;
                    try
                    {
                        q.ToList()[0].Title.ToString();
                        bIfExist = true;
                    }
                    catch { }
                    if (bIfExist == true)
                    {
                        ModelState.AddModelError("Relationship", $"Can not register duplicate record. {formData.Title} Relationship is already registered");
                    }
                    else
                    {
                        await _relationshipTypeServices.AddRelationshiptypeAsync(new RelationShipType
                        {
                            DateTimeAdded    = DateTimeOffset.Now,
                            Title            = formData.Title,
                            DateTimeModified = DateTimeOffset.Now,
                            UserAccount      = User.Identity.Name,
                        });

                        TempData["Message"] = "Relationship Successfully Added";
                        _logger.LogInformation($"Success: successfully added {formData.Title} relationship record by user={@User.Identity.Name.Substring(4)}");
                        return(RedirectToAction("add"));
                    }
                }
            }
            catch (ApplicationException error)
            {
                ModelState.AddModelError("Relationship", $"Failed to register record. {formData.Title} Contact IT ServiceDesk for support.");
                _logger.LogError(
                    error,
                    $"FAIL: failed to register {formData.Title} Relationship. Internal Application Error; user={@User.Identity.Name.Substring(4)}");
            }
            return(View(formData));
        }
 public NewRelationshipTypePage()
 {
     InitializeComponent();
     BindingContext = viewModel = new NewRelationshipViewModel();
 }