public void GetDetailedGroupResultTest() { Group group = Db.Groups.FirstOrDefault(); Period period = Db.Periods.OrderBy(x => x.Created).Where(x => x.SectionId == group.SectionId).FirstOrDefault(); ResultBL resultBL = new ResultBL(); DetailedGroupResultViewModel result = resultBL.GetDetailedGroupResult(group, period); Console.WriteLine("Periodio:" + result.PeriodNumber); Console.WriteLine("=========================================="); foreach (var item in result.Results) { Console.WriteLine("Nombre de Producto: " + item.ProductName); Console.WriteLine("Número de Producto: " + item.ProductNumber); Console.WriteLine("Costo de inventario Final: " + item.FinalStockCost); Console.WriteLine("Costo de Demanda Insatisfecha: " + item.UnsatisfiedDemandCost); Console.WriteLine("Costo de Orden: " + item.OrderCost); Console.WriteLine("-------------------------------------"); } }
public DetailedGroupResultViewModel GetDetailedGroupResult(Group group, Period period) { DetailedGroupResultViewModel result = new DetailedGroupResultViewModel(); var resultList = group.Balances .Where(x => x.Period == period) .Select(x => new ResultViewModel { ProductName = x.Product.Name, ProductNumber = x.Product.Number.ToString(), FinalStockCost = x.FinalStockCostPast, UnsatisfiedDemandCost = x.DissatisfiedCostPast, OrderCost = x.OrderCost }) .ToList(); result.PeriodNumber = group.Section.Periods.OrderBy(x => x.Created).ToList().IndexOf(period); result.Results = resultList; return(result); }
public async Task <ActionResult> Details(Guid?PeriodId) { if (PeriodId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Group group = await Db.Groups.Where(x => x.Users.Select(t => t.Id).Contains(CurrentUser.Id)).FirstOrDefaultAsync(); Period period = await Db.Periods.Where(x => x.Id == PeriodId).FirstOrDefaultAsync(); if (group == null || period == null) { return(HttpNotFound()); } ResultBL resultBL = new ResultBL(); ViewBag.Section = period.Section; ViewBag.Group = group; ViewBag.PeriodNumber = group.Section.Periods.OrderBy(x => x.Created).ToList().IndexOf(period); DetailedGroupResultViewModel detailedResult = resultBL.GetDetailedGroupResult(group, period); return(View("DetailsStudents", detailedResult)); }