public async Task <IActionResult> AddBudget([FromBody] Budget budget) { if (budget == null || !ModelState.IsValid) { return(BadRequest(new ErrorModel <object>(ProjectCodes.Form_Generic_Error))); } try { budget = TimeUtils.GetBudgetUtc(budget); if (await _budgetRepository.Exists(budget.UserId, budget.FromDate, budget.ToDate)) { return(BadRequest(new ErrorModel <object>(ProjectCodes.Budget_Already_Present))); } var result = await _budgetRepository.AddBudget(budget); return(Ok(result)); } catch (Exception e) { Console.WriteLine(e.ToString()); return(BadRequest(new ErrorModel <object>(ProjectCodes.Generic_Error))); } }