public ActionResult SaveBalanceItems(int clientId, BalanceItems items) { _factory.GetBalanceService().SaveItems(clientId, items); return(new JsonResult { Data = true }); }
public BalanceItems GetItems(int clientId) { var itemsDao = _dbContext.BalanceReport.Where(c => c.ClientId.Equals(clientId)).OrderBy(c => c.RowId).ToList(); var items = Converter.ConvertList <BalanceReportItemDao, BalanceReportItem>(itemsDao); var result = new BalanceItems { Actives = items.Where(c => c.Type.ToUpper().Equals("AKTYWA")).ToList(), Passives = items.Where(c => c.Type.ToUpper().Equals("PASYWA")).ToList() }; return(result); }
public void SaveItems(int clientId, BalanceItems items) { var flatenedItems = new List <BalanceReportItem>(); flatenedItems.AddRange(items.Actives); flatenedItems.AddRange(items.Passives); var result = _dbContext.BalanceReport.Where(c => c.ClientId.Equals(clientId)).ToList(); foreach (var row in result) { var newItem = flatenedItems.FirstOrDefault(c => c.Id.Equals(row.Id)); if (newItem != null) { row.Formula = newItem.Formula; } _dbContext.BalanceReport.AddOrUpdate(row); } _dbContext.SaveChanges(); }