public ActionResult GetItemById(long id) { ItemDomainDTO itemDTO = _itemBusiness.GetItemById(id, OrgId); itemDTO.UnitName = _unitBusiness.GetUnitOneByOrgId(itemDTO.UnitId, OrgId).UnitName; itemDTO.ItemTypeName = _itemTypeBusiness.GetItemType(itemDTO.ItemTypeId, OrgId).ItemName; ItemViewModel itemViewModel = new ItemViewModel(); AutoMapper.Mapper.Map(itemDTO, itemViewModel); return(Json(itemViewModel)); }
public bool SaveProductionStockIn(List <ProductionStockDetailDTO> productionStockDetailDTOs, long userId, long orgId) { List <ProductionStockDetail> productionStockDetails = new List <ProductionStockDetail>(); foreach (var item in productionStockDetailDTOs) { ProductionStockDetail stockDetail = new ProductionStockDetail(); stockDetail.WarehouseId = item.WarehouseId; stockDetail.ItemTypeId = item.ItemTypeId; stockDetail.ItemId = item.ItemId; stockDetail.Quantity = item.Quantity; stockDetail.OrganizationId = orgId; stockDetail.EUserId = userId; stockDetail.Remarks = item.Remarks; stockDetail.UnitId = _itemBusiness.GetItemById(item.ItemId.Value, orgId).UnitId; stockDetail.EntryDate = DateTime.Now; stockDetail.StockStatus = "Stock-In"; stockDetail.RefferenceNumber = item.RefferenceNumber; var productionInfo = _productionStockInfoBusiness.GetAllProductionStockInfoByOrgId(orgId).Where(o => o.ItemTypeId == item.ItemTypeId && o.ItemId == item.ItemId).FirstOrDefault(); if (productionInfo != null) { productionInfo.StockInQty += item.Quantity; _productionStockInfoRepository.Update(productionInfo); } else { ProductionStockInfo productionStockInfo = new ProductionStockInfo(); productionStockInfo.WarehouseId = item.WarehouseId; productionStockInfo.ItemTypeId = item.ItemTypeId; productionStockInfo.ItemId = item.ItemId; productionStockInfo.UnitId = stockDetail.UnitId; productionStockInfo.StockInQty = item.Quantity; productionStockInfo.StockOutQty = 0; productionStockInfo.OrganizationId = orgId; productionStockInfo.EUserId = userId; productionStockInfo.EntryDate = DateTime.Now; _productionStockInfoRepository.Insert(productionStockInfo); } productionStockDetails.Add(stockDetail); } _productionStockDetailRepository.InsertAll(productionStockDetails); return(_productionStockDetailRepository.Save()); }
public bool SaveWarehouseStockIn(List <WarehouseStockDetailDTO> warehouseStockDetailDTO, long userId, long orgId) { List <WarehouseStockDetail> warehouseStockDetails = new List <WarehouseStockDetail>(); foreach (var item in warehouseStockDetailDTO) { WarehouseStockDetail stockDetail = new WarehouseStockDetail(); stockDetail.WarehouseId = item.WarehouseId; stockDetail.ItemTypeId = item.ItemTypeId; stockDetail.ItemId = item.ItemId; stockDetail.Quantity = item.Quantity; stockDetail.OrganizationId = orgId; stockDetail.EUserId = userId; stockDetail.Remarks = item.Remarks; stockDetail.UnitId = _itemBusiness.GetItemById(item.ItemId.Value, orgId).UnitId; stockDetail.EntryDate = DateTime.Now; stockDetail.StockStatus = "Stock-In"; var warehouseInfo = _warehouseStockInfoBusiness.GetAllWarehouseStockInfoByOrgId(orgId).Where(o => o.ItemTypeId == item.ItemTypeId && o.ItemId == item.ItemId).FirstOrDefault(); if (warehouseInfo != null) { warehouseInfo.StockInQty += item.Quantity; warehouseStockInfoRepository.Update(warehouseInfo); } else { WarehouseStockInfo warehouseStockInfo = new WarehouseStockInfo(); warehouseStockInfo.WarehouseId = item.WarehouseId; warehouseStockInfo.ItemTypeId = item.ItemTypeId; warehouseStockInfo.ItemId = item.ItemId; warehouseStockInfo.UnitId = stockDetail.UnitId; warehouseStockInfo.StockInQty = item.Quantity; warehouseStockInfo.StockOutQty = 0; warehouseStockInfo.OrganizationId = orgId; warehouseStockInfo.EUserId = userId; warehouseStockInfo.EntryDate = DateTime.Now; warehouseStockInfoRepository.Insert(warehouseStockInfo); } warehouseStockDetails.Add(stockDetail); } warehouseStockDetailRepository.InsertAll(warehouseStockDetails); return(warehouseStockDetailRepository.Save()); }