Ejemplo n.º 1
0
 public bool DeleteLocalPurchase(LocalPurchase localPurchase)
 {
     if(localPurchase==null) return false;
        _unitOfWork.LocalPurchaseRepository.Delete(localPurchase);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 2
0
        public bool Approve(LocalPurchase localPurchase)
        {
            try
               {
               localPurchase.StatusID = (int) LocalPurchaseStatus.Approved;
               _unitOfWork.LocalPurchaseRepository.Edit(localPurchase);
               foreach (var localPurchaseDetail in localPurchase.LocalPurchaseDetails)
               {
                   var reciptAllocaltion = new ReceiptAllocation()
                       {
                           ReceiptAllocationID = Guid.NewGuid(),
                           ProgramID = localPurchase.ProgramID,
                           CommodityID = localPurchase.CommodityID,
                           DonorID = localPurchase.DonorID,
                           ETA = localPurchase.DateCreated,
                           SINumber = localPurchase.ShippingInstruction.Value,
                           QuantityInMT = localPurchaseDetail.AllocatedAmount,
                           HubID = localPurchaseDetail.HubID,
                           CommoditySourceID = 3, //Local Purchase
                           ProjectNumber = localPurchase.ProjectCode,
                           //PurchaseOrder = localPurchase.PurchaseOrder,
                           PartitionID = 0,
                           IsCommited = false
                       };
                   _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
                   _unitOfWork.Save();
               }
               return true;
               }
               catch (Exception)
               {

               return false;
               }
        }
Ejemplo n.º 3
0
        public bool DeleteLocalPurchae(LocalPurchase localPurchase)
        {
            try
            {
                var localPurchaseDetail =
                    _unitOfWork.LocalPurchaseDetailRepository.FindBy(
                        d => d.LocalPurchaseID == localPurchase.LocalPurchaseID);
                foreach (var purchaseDetail in localPurchaseDetail)
                {
                    _unitOfWork.LocalPurchaseDetailRepository.Delete(purchaseDetail);
                }
                _unitOfWork.LocalPurchaseRepository.Delete(localPurchase);
                _unitOfWork.Save();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }
Ejemplo n.º 4
0
 public bool AddLocalPurchase(LocalPurchase localPurchase)
 {
     _unitOfWork.LocalPurchaseRepository.Add(localPurchase);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 5
0
 public bool EditLocalPurchase(LocalPurchase localPurchase)
 {
     _unitOfWork.LocalPurchaseRepository.Edit(localPurchase);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 6
0
        public bool DelteLocalPurchaseAllocation(LocalPurchase localPurchase)
        {
            try
            {
                var receiptAllocation =
                    _unitOfWork.ReceiptAllocationReository.FindBy(
                        c => c.CommoditySourceID == CommoditySourceConst.Constants.LOCALPURCHASE && c.SINumber == localPurchase.ShippingInstruction.Value && c.ProjectNumber == localPurchase.ProjectCode);

                foreach (var allocation in receiptAllocation)
                {
                    _unitOfWork.ReceiptAllocationReository.Delete(allocation);
                }
                _unitOfWork.Save();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }
Ejemplo n.º 7
0
        private bool SaveNewLocalPurchase(LocalPurchaseWithDetailViewModel localPurchaseWithDetailViewModel, int sippingInstractionID)
        {
            try
            {

                var localPurchase = new LocalPurchase()
                {
                    DateCreated = DateTime.Now,
                    CommodityID = localPurchaseWithDetailViewModel.CommodityID,
                    DonorID = localPurchaseWithDetailViewModel.DonorID,
                    ProgramID = localPurchaseWithDetailViewModel.ProgramID,
                    ShippingInstructionID = sippingInstractionID,
                    PurchaseOrder = localPurchaseWithDetailViewModel.PurchaseOrder,
                    SupplierName = localPurchaseWithDetailViewModel.SupplierName,
                    Quantity = localPurchaseWithDetailViewModel.Quantity,
                    ReferenceNumber = localPurchaseWithDetailViewModel.ReferenceNumber,
                    ProjectCode = localPurchaseWithDetailViewModel.ProjectCode,
                    StatusID = (int)LocalPurchaseStatus.Draft,

                };

                foreach (var localPurchaseDetail in localPurchaseWithDetailViewModel.LocalPurchaseDetailViewModels
                    .Select(localPurchaseDetail => new LocalPurchaseDetail()
                {
                    HubID = localPurchaseDetail.HubID,
                    AllocatedAmount = localPurchaseDetail.AllocatedAmonut,
                    RecievedAmount = localPurchaseDetail.RecievedAmonut,
                    LocalPurchase = localPurchase
                }))
                {
                    _localPurchaseDetailService.AddLocalPurchaseDetail(localPurchaseDetail);
                }
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }