public async Task <IActionResult> CreateGroupInvitation([FromBody] GroupInvitationViewModel model) { try { if (ModelState.IsValid) { GroupInvitation invitation = new GroupInvitation() { GroupId = model.GroupId, ContactInfo = model.ContactInfo, ContactPreference = model.ContactPreference, IsAccepted = model.IsAccepted, CreatedAt = model.CreatedAt }; await _groupManager.CreateGroupInvitation(invitation); return(Ok(ApiResponse(ApiResponseStatus.Success, invitation, $@"Invitation added successfully added."))); } return(BadRequest(ApiResponse(ApiResponseStatus.Fail, GetModelStateErrors(ModelState), "Model validation failure."))); } catch (Exception e) { _logger.LogError(e.Message); return(HandleException("1", e, "An error occurred while adding record. Please try again later.")); } }