<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Cats.Data.UnitWork;
using Cats.Models;
using Cats.Models.Constant;

namespace Cats.Services.Logistics
{

    public class LoanReciptPlanService:ILoanReciptPlanService
   {
       private readonly  IUnitOfWork _unitOfWork;
      

       public LoanReciptPlanService(IUnitOfWork unitOfWork)
       {
           this._unitOfWork = unitOfWork;
       }
       #region Default Service Implementation
       public bool AddLoanReciptPlan(LoanReciptPlan entity)
       {
           _unitOfWork.LoanReciptPlanRepository.Add(entity);
           _unitOfWork.Save();
           return true;
           
       }
       public bool EditLoanReciptPlan(LoanReciptPlan entity)
       {
           _unitOfWork.LoanReciptPlanRepository.Edit(entity);
           _unitOfWork.Save();
           return true;

       }
         public bool DeleteLoanReciptPlan(LoanReciptPlan entity)
        {
             if(entity==null) return false;
           _unitOfWork.LoanReciptPlanRepository.Delete(entity);
           _unitOfWork.Save();
           return true;
        }
       public  bool DeleteById(int id)
       {
           var entity = _unitOfWork.LoanReciptPlanRepository.FindById(id);
           if(entity==null) return false;
           _unitOfWork.LoanReciptPlanRepository.Delete(entity);
           _unitOfWork.Save();
           return true;
       }
       public List<LoanReciptPlan> GetAllLoanReciptPlan()
       {
           return _unitOfWork.LoanReciptPlanRepository.GetAll();
       } 
       public LoanReciptPlan FindById(int id)
       {
           return _unitOfWork.LoanReciptPlanRepository.FindById(id);
       }
       public List<LoanReciptPlan> FindBy(Expression<Func<LoanReciptPlan, bool>> predicate)
       {
           return _unitOfWork.LoanReciptPlanRepository.FindBy(predicate);
       }
       public bool ApproveRecieptPlan(LoanReciptPlan loanReciptPlan)
       {
           if (loanReciptPlan != null)
           {
               loanReciptPlan.StatusID = (int)LocalPurchaseStatus.Approved;
               _unitOfWork.LoanReciptPlanRepository.Edit(loanReciptPlan);
               var reciptAllocaltion = new ReceiptAllocation()
               {
                   ReceiptAllocationID = Guid.NewGuid(),
                   ProgramID = loanReciptPlan.ProgramID,
                   CommodityID = loanReciptPlan.CommodityID,
                   ETA = loanReciptPlan.CreatedDate,
                   SINumber = loanReciptPlan.ShippingInstruction.Value,
                   QuantityInMT = loanReciptPlan.Quantity,
                   //HubID = loanReciptPlan.DestinationHubID,
                   CommoditySourceID = loanReciptPlan.CommoditySourceID,
                   ProjectNumber = loanReciptPlan.ProjectCode,
                   //SourceHubID = loanReciptPlan.SourceHubID,
                   PartitionID = 0,
                   IsCommited = false
               };
               _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
               _unitOfWork.Save();
               return true;

           }
           return false;
       }
       #endregion

       public void Dispose()
       {
           _unitOfWork.Dispose();
           
       }
       
   }
   }
   
         
      
<commit_msg>Modified ReceiptPlan sending to hub bug<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Cats.Data.UnitWork;
using Cats.Models;
using Cats.Models.Constant;

namespace Cats.Services.Logistics
{

    public class LoanReciptPlanService:ILoanReciptPlanService
   {
       private readonly  IUnitOfWork _unitOfWork;
      

       public LoanReciptPlanService(IUnitOfWork unitOfWork)
       {
           this._unitOfWork = unitOfWork;
       }
       #region Default Service Implementation
       public bool AddLoanReciptPlan(LoanReciptPlan entity)
       {
           _unitOfWork.LoanReciptPlanRepository.Add(entity);
           _unitOfWork.Save();
           return true;
           
       }
       public bool EditLoanReciptPlan(LoanReciptPlan entity)
       {
           _unitOfWork.LoanReciptPlanRepository.Edit(entity);
           _unitOfWork.Save();
           return true;

       }
         public bool DeleteLoanReciptPlan(LoanReciptPlan entity)
        {
             if(entity==null) return false;
           _unitOfWork.LoanReciptPlanRepository.Delete(entity);
           _unitOfWork.Save();
           return true;
        }
       public  bool DeleteById(int id)
       {
           var entity = _unitOfWork.LoanReciptPlanRepository.FindById(id);
           if(entity==null) return false;
           _unitOfWork.LoanReciptPlanRepository.Delete(entity);
           _unitOfWork.Save();
           return true;
       }
       public List<LoanReciptPlan> GetAllLoanReciptPlan()
       {
           return _unitOfWork.LoanReciptPlanRepository.GetAll();
       } 
       public LoanReciptPlan FindById(int id)
       {
           return _unitOfWork.LoanReciptPlanRepository.FindById(id);
       }
       public List<LoanReciptPlan> FindBy(Expression<Func<LoanReciptPlan, bool>> predicate)
       {
           return _unitOfWork.LoanReciptPlanRepository.FindBy(predicate);
       }
       public bool ApproveRecieptPlan(LoanReciptPlan loanReciptPlan)
       {
           if (loanReciptPlan != null)
           {
               loanReciptPlan.StatusID = (int)LocalPurchaseStatus.Approved;
               _unitOfWork.LoanReciptPlanRepository.Edit(loanReciptPlan);
               foreach (var loan in loanReciptPlan.LoanReciptPlanDetails)
               {

                   var reciptAllocaltion = new ReceiptAllocation()
                       {
                           ReceiptAllocationID = Guid.NewGuid(),
                           ProgramID = loanReciptPlan.ProgramID,
                           CommodityID = loanReciptPlan.CommodityID,
                           ETA = loanReciptPlan.CreatedDate,
                           SINumber = loanReciptPlan.ShippingInstruction.Value,
                           QuantityInMT = loan.RecievedQuantity,
                           HubID = loan.HubID,
                           CommoditySourceID = loanReciptPlan.CommoditySourceID,
                           ProjectNumber = loanReciptPlan.ProjectCode,
                           //SourceHubID = loanReciptPlan.SourceHubID,
                           PartitionID = 0,
                           IsCommited = false
                       };

                   _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
                   _unitOfWork.Save();
               }
               return true;

           }
           return false;
       }
       #endregion

       public void Dispose()
       {
           _unitOfWork.Dispose();
           
       }
       
   }
   }
   
         
      

{'fraction_non_alphanumeric': 0.06726718000871713, 'fraction_numerical': 0.0002905709719599012, 'mean_word_length': 1.7306624355414517, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1214520', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1846, 'n_words': 286}