public void AddExpenseWeb([FromBody] string recurringincomeadd) { try { ReccuringIncomeDB _recurringincome = new ReccuringIncomeDB(); string reccuringIncomeToAddString = recurringincomeadd; string[] elements = reccuringIncomeToAddString.Split(','); foreach (string it in elements) { decimal _reccuringIncomeAmount = decimal.Parse(elements[0]); DateTime _reccuringDateFrom = DateTime.Parse(elements[1]); DateTime _reccuringDateUntil = DateTime.Parse(elements[2]); int _userid = Int32.Parse(FrontendController.Instance().userId()); _recurringincome.reccuringincomeAmount = _reccuringIncomeAmount; _recurringincome.reccuringincomeDateFrom = _reccuringDateFrom; _recurringincome.reccuringincomeDateUntil = _reccuringDateUntil; _recurringincome.userId = _userid; } using (var context = new Data.Smart_Saver_APIContext()) { context.ReccuringIncomeDB.Add(_recurringincome); context.SaveChanges(); } } catch (Exception e) { _logger.LogError(e.ToString()); } }
public void AddIncome(decimal amount, DateTime dateFrom, DateTime dateUntil) { try { ReccuringIncomeDB _income = new ReccuringIncomeDB() { reccuringincomeAmount = amount, reccuringincomeDateFrom = dateFrom, reccuringincomeDateUntil = dateUntil, userId = Int32.Parse(FrontendController.Instance().userInfo()) }; using (var context = new Data.Smart_Saver_APIContext()) { context.ReccuringIncomeDB.Add(_income); context.SaveChanges(); } } catch (Exception e) { _logger.LogError(e.ToString()); } }