public HttpResponseMessage GetItem(Guid id, [FromUri] int itemid) { var item = _companyRepository.GetItem(itemid); ViewModels.ActiveItem res = new ViewModels.ActiveItem(); res.BarCode = item.Code; res.Description = item.Description; res.Number = item.ItemNumber; res.Name = item.Name; res.Id = item.Id; res.CreatedAt = item.CreatedAt; res.Readonly = item.Source == ItemSource.Import; return(Request.CreateResponse(HttpStatusCode.OK, res)); }
public HttpResponseMessage GetItem(Guid inventorizationId, [FromUri] int id) { var item = inventorizationDomain.GetItem(id); ViewModels.ActiveItem res = new ViewModels.ActiveItem(); res.BarCode = item.Code; res.Description = item.Description; res.Number = item.ItemNumber; res.Name = item.Name; res.Id = item.Id; res.CreatedAt = item.CreatedAt; res.Readonly = item.Source == ItemSource.Import; var rests = inventorizationDomain.GetRests(inventorizationId, item.Code); res.QuantityPlan = rests?.Count; var actions = inventorizationDomain.GetActionsByCode(inventorizationId, item.Code); var zones = zoneDomain.GetZones(actions.Select(x => x.Zone).ToArray()); var actionsByType = actions.Where(a => a.BarCode == item.Code).GroupBy(a => a.Type); res.Actions = new List <ItemDetails>(); foreach (var action in actionsByType) { res.Actions.Add(new ItemDetails() { Type = action.Key, ZoneDetails = action.Select(x => new ActionZoneDetails() { Quantity = x.Quantity, Zone = zones.FirstOrDefault(z => z.Id == x.Zone).Name }).ToList() }); } return(Request.CreateResponse(HttpStatusCode.OK, res)); }