Esempio n. 1
0
        public List <ViewModels.InternalMovementLogViewModel> GetAllInternalMovmentLog()
        {
            List <ViewModels.InternalMovementLogViewModel> internalMovmentLogViewModel = new List <ViewModels.InternalMovementLogViewModel>();

            ViewModels.InternalMovementLogViewModel _internalMovment;
            var movements = _unitOfWork.InternalMovementRepository.GetAll();

            var internalMovments = (from c in movements select c).ToList();

            foreach (var internalMovment in internalMovments)
            {
                foreach (var transaction in internalMovment.TransactionGroup.Transactions)
                {
                    if (transaction.TransactionGroupID == internalMovment.TransactionGroupID)
                    {
                        if (transaction.QuantityInMT >= 0)
                        {
                            var fromStore = _unitOfWork.TransactionRepository.FindBy(c => c.TransactionGroupID == internalMovment.TransactionGroupID && c.QuantityInMT < 0).Select(q => q.Store.Name + " - " + q.Store.StoreManName).FirstOrDefault();
                            var fromStack = _unitOfWork.TransactionRepository.FindBy(c => c.TransactionGroupID == internalMovment.TransactionGroupID && c.QuantityInMT < 0).Select(q => q.Stack.Value).FirstOrDefault();
                            var commodity = _unitOfWork.CommodityRepository.FindBy(c => c.CommodityID == transaction.CommodityID).Select(c => c.Name).Single();

                            _internalMovment = new ViewModels.InternalMovementLogViewModel();
                            _internalMovment.TransactionId             = transaction.TransactionID;
                            _internalMovment.FromStore                 = fromStore; // (from c in db.Transactions where ((c.TransactionGroupID == internalMovment.TransactionGroupID) && (c.QuantityInMT < 0)) select (c.Store.Name + " - " + c.Store.StoreManName)).FirstOrDefault();
                            _internalMovment.FromStack                 = fromStack; // (from c in db.Transactions where ((c.TransactionGroupID == internalMovment.TransactionGroupID) && (c.QuantityInMT < 0)) select c.Stack.Value).FirstOrDefault();
                            _internalMovment.SelectedDate              = internalMovment.TransferDate;
                            _internalMovment.ToStore                   = string.Format("{0} - {1} ", transaction.Store.Name, transaction.Store.StoreManName);
                            _internalMovment.ToStack                   = transaction.Stack.Value;
                            _internalMovment.RefernaceNumber           = internalMovment.ReferenceNumber;
                            _internalMovment.CommodityName             = commodity;// repository.Commodity.FindById(transaction.CommodityID).Name;
                            _internalMovment.Program                   = transaction.Program.Name;
                            _internalMovment.ProjectCodeName           = transaction.ProjectCode.Value;
                            _internalMovment.ShippingInstructionNumber = transaction.ShippingInstruction.Value;
                            _internalMovment.Unit           = transaction.Unit.Name;
                            _internalMovment.QuantityInUnit = transaction.QuantityInUnit;
                            _internalMovment.QuantityInMt   = transaction.QuantityInMT;
                            _internalMovment.Reason         = internalMovment.Detail.Description;
                            _internalMovment.Note           = internalMovment.Notes;
                            _internalMovment.ApprovedBy     = internalMovment.ApprovedBy;
                            _internalMovment.Reason         = internalMovment.Detail.Name;
                            internalMovmentLogViewModel.Add(_internalMovment);
                        }
                    }
                }
            }

            return(internalMovmentLogViewModel);
        }
        public List<ViewModels.InternalMovementLogViewModel> GetAllInternalMovmentLog()
        {
            List<ViewModels.InternalMovementLogViewModel> internalMovmentLogViewModel = new List<ViewModels.InternalMovementLogViewModel>();
            ViewModels.InternalMovementLogViewModel _internalMovment;
            var movements = _unitOfWork.InternalMovementRepository.GetAll();

            var internalMovments = (from c in movements select c).ToList();

            foreach (var internalMovment in internalMovments)
            {
                foreach (var transaction in internalMovment.TransactionGroup.Transactions)
                {
                    if (transaction.TransactionGroupID == internalMovment.TransactionGroupID)
                    {
                        if (transaction.QuantityInMT >= 0)
                        {
                            var fromStore = _unitOfWork.TransactionRepository.FindBy(c=>c.TransactionGroupID == internalMovment.TransactionGroupID && c.QuantityInMT < 0).Select(q=>q.Store.Name + " - " + q.Store.StoreManName).FirstOrDefault();
                            var fromStack = _unitOfWork.TransactionRepository.FindBy(c => c.TransactionGroupID == internalMovment.TransactionGroupID && c.QuantityInMT < 0).Select(q => q.Stack.Value).FirstOrDefault();
                            var commodity = _unitOfWork.CommodityRepository.FindBy(c=>c.CommodityID == transaction.CommodityID).Select(c => c.Name).Single();

                            _internalMovment = new ViewModels.InternalMovementLogViewModel();
                            _internalMovment.TransactionId = transaction.TransactionID;
                            _internalMovment.FromStore = fromStore;// (from c in db.Transactions where ((c.TransactionGroupID == internalMovment.TransactionGroupID) && (c.QuantityInMT < 0)) select (c.Store.Name + " - " + c.Store.StoreManName)).FirstOrDefault();
                            _internalMovment.FromStack = fromStack;// (from c in db.Transactions where ((c.TransactionGroupID == internalMovment.TransactionGroupID) && (c.QuantityInMT < 0)) select c.Stack.Value).FirstOrDefault();
                            _internalMovment.SelectedDate = internalMovment.TransferDate;
                            _internalMovment.ToStore = string.Format("{0} - {1} ", transaction.Store.Name, transaction.Store.StoreManName);
                            _internalMovment.ToStack = transaction.Stack.Value;
                            _internalMovment.RefernaceNumber = internalMovment.ReferenceNumber;
                            _internalMovment.CommodityName = commodity;// repository.Commodity.FindById(transaction.CommodityID).Name;
                            _internalMovment.Program = transaction.Program.Name;
                            _internalMovment.ProjectCodeName = transaction.ProjectCode.Value;
                            _internalMovment.ShippingInstructionNumber = transaction.ShippingInstruction.Value;
                            _internalMovment.Unit = transaction.Unit.Name;
                            _internalMovment.QuantityInUnit = transaction.QuantityInUnit;
                            _internalMovment.QuantityInMt = transaction.QuantityInMT;
                            _internalMovment.Reason = internalMovment.Detail.Description;
                            _internalMovment.Note = internalMovment.Notes;
                            _internalMovment.ApprovedBy = internalMovment.ApprovedBy;
                            _internalMovment.Reason = internalMovment.Detail.Name;
                            internalMovmentLogViewModel.Add(_internalMovment);
                        }
                    }
                }
            }

            return internalMovmentLogViewModel;
        }