public AddBillResponse AddBill([FromBody] AddBillRequest billRequest) { var response = new AddBillResponse(); try { if (_userService.AuthenticateSession(Request.Headers["Authorization"].ToString()) == false) { response.AddError("The authorization credentails were invalid", ErrorCode.SESSION_INVALID); return(response); } ActiveUser user = _userService.GetUserInformationFromAuthHeader(Request.Headers["Authorization"].ToString()); if (user.HouseId == 0) { response.AddError("You must belong to a household to add bills", ErrorCode.USER_NOT_IN_HOUSEHOLD); return(response); } AddBill bill = new AddBill { Name = billRequest.Name, Due = billRequest.Due, PeopleIds = billRequest.PeopleIds, RecurringType = billRequest.RecurringType, TotalAmount = billRequest.TotalAmount, HouseId = user.HouseId }; BillValidator.CheckIfValidBill(bill); response.Id = _billRepository.AddBill(bill); if (user.HouseId == 1) { _discordService.AddBillNotification(billRequest.Name, billRequest.Due, billRequest.TotalAmount); } response.Notifications = new List <string> { $"The bill '{billRequest.Name}' has been added" }; } catch (ErrorCodeException exception) { response.AddError($"An unexpected exception occured: {exception}", billRequest, exception.Code); } catch (Exception exception) { response.AddError($"An unexpected exception occured: {exception}", billRequest); } return(response); }