Пример #1
0
        //public List<VLCExpenseDetail> GetAllVLCExpenseDetailByDockId(int docKId)
        //{
        //    var vlcExpenses = _repository.VLCExpenseDetails.Where(v => v.DockMilkCollectionId == docKId).ToList<Sql.VLCExpenseDetail>();
        //    return vlcExpenses;
        //}

        //public VLCExpenseDetail GetVLCExpenseDetailByDockCollectionId(int dockMilkCollectionId)
        //{
        //    var vlcExpenses = _repository.VLCExpenseDetails.Where(v => v.DockMilkCollectionId == dockMilkCollectionId).FirstOrDefault();
        //    return vlcExpenses;
        //}

        public void Add(VLCExpenseDetail vlcExpense)
        {
            if (vlcExpense != null)
            {
                _repository.VLCExpenseDetails.Add(vlcExpense);
            }
        }
Пример #2
0
 public void Update(VLCExpenseDetail vlcExpense)
 {
     if (vlcExpense != null)
     {
         _repository.Entry <Sql.VLCExpenseDetail>(vlcExpense).State = System.Data.Entity.EntityState.Modified;
     }
 }
Пример #3
0
        public static VLCExpenseDTO ConvertToVLCExpenseDTO(VLCExpenseDetail vLCExpenseDetail)
        {
            VLCExpenseDTO vLCExpenseDTO = new VLCExpenseDTO();

            if (vLCExpenseDetail != null)
            {
                vLCExpenseDTO.VLCExpenseId = vLCExpenseDetail.VLCExpenseId;
                vLCExpenseDTO.CreatedBy    = vLCExpenseDetail.CreatedBy;
                vLCExpenseDTO.CreatedDate  = vLCExpenseDetail.CreatedDate;
                vLCExpenseDTO.VLCId        = vLCExpenseDetail.VLCId;
                vLCExpenseDTO.VLCName      = vLCExpenseDetail.VLC.VLCName;

                VLCExpenseEnum vLCExpenseReason;
                Enum.TryParse <VLCExpenseEnum>(vLCExpenseDetail.ExpenseReason.ToString(), out vLCExpenseReason);
                vLCExpenseDTO.ExpenseReason = vLCExpenseReason;

                vLCExpenseDTO.VLCExpenseId    = vLCExpenseDetail.VLCExpenseId;
                vLCExpenseDTO.ModifiedDate    = vLCExpenseDetail.ModifiedDate;
                vLCExpenseDTO.ModifiedBy      = vLCExpenseDetail.ModifiedBy;
                vLCExpenseDTO.ExpenseComments = vLCExpenseDetail.ExpenseComments;
                vLCExpenseDTO.PaymentCrAmount = vLCExpenseDetail.PaymentCrAmount.GetValueOrDefault();
                vLCExpenseDTO.ExpenseDate     = vLCExpenseDetail.ExpenseDate;
                vLCExpenseDTO.PaymentDrAmount = vLCExpenseDetail.PaymentDrAmount.GetValueOrDefault();
            }

            return(vLCExpenseDTO);
        }
Пример #4
0
 public static void ConvertToVLCExpenseDetailEntity(ref VLCExpenseDetail vLCExpenseDetail, VLCExpenseDTO vLCExpenseDTO, bool isUpdate)
 {
     vLCExpenseDetail.VLCId = vLCExpenseDTO.VLCId;
     if (string.IsNullOrWhiteSpace(vLCExpenseDTO.ExpenseComments) == false)
     {
         vLCExpenseDetail.ExpenseComments = vLCExpenseDTO.ExpenseComments;
         vLCExpenseDetail.ExpenseDate     = vLCExpenseDTO.ExpenseDate.HasValue ? vLCExpenseDTO.ExpenseDate.Value : DateTime.Now.Date;
         vLCExpenseDetail.ExpenseReason   = (int)vLCExpenseDTO.ExpenseReason;
         vLCExpenseDTO.PaymentCrAmount    = vLCExpenseDTO.PaymentCrAmount;
         vLCExpenseDTO.PaymentDrAmount    = vLCExpenseDTO.PaymentDrAmount;
         vLCExpenseDTO.CreatedBy          = "User";
         vLCExpenseDTO.CreatedDate        = DateTime.Now.Date;
     }
 }
Пример #5
0
        public ResponseDTO GetVLCExpensesById(int value)
        {
            ResponseDTO      response         = new ResponseDTO();
            VLCExpenseDetail vLCExpenseDetail = unitOfWork.VLCExpenseDetailRepository.GetExpenseByExpenseId(value);
            VLCExpenseDTO    vLCExpense       = new VLCExpenseDTO();

            vLCExpense = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpenseDetail);
            if (vLCExpense != null)
            {
                response.Data    = vLCExpense;
                response.Status  = true;
                response.Message = "VLC Expense by ID";
            }
            else
            {
                response.Status  = false;
                response.Message = "VLC Expense not found !";
            }
            return(response);
        }
Пример #6
0
        //TODO: Vimal please check why you are checking vlc id in DC repository
        //Date: 09-Sep-19
        public ResponseDTO AddVLCExpenseDetail(VLCExpenseDTO vLCExpenseDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            //CC: By Anil see comment above
            //var vLC = unitOfWork.DistributionCenterRepository.GetById(vLCExpenseDTO.VLCId);
            var vLC = unitOfWork.VLCRepository.GetById(vLCExpenseDTO.VLCId);

            if (vLC != null)
            {
                VLCExpenseDetail vLCExpenseDetail = AddExpense(vLCExpenseDTO);
                vLCExpenseDTO = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpenseDetail);

                responseDTO.Status  = true;
                responseDTO.Message = "VLC Expense Detail Added Successfully";
                responseDTO.Data    = vLCExpenseDTO;
                return(responseDTO);
            }
            else
            {
                throw new PlatformModuleException("VLC Not Found");
            }
        }
Пример #7
0
        private VLCExpenseDetail AddExpense(VLCExpenseDTO vLCExpenseDTO)
        {
            VLCExpenseDetail vLCExpenseDetail = new VLCExpenseDetail();

            vLCExpenseDetail.VLCExpenseId    = unitOfWork.DashboardRepository.NextNumberGenerator("VLCExpenseDetail");
            vLCExpenseDetail.VLCId           = vLCExpenseDTO.VLCId;
            vLCExpenseDetail.ExpenseReason   = (int)vLCExpenseDTO.ExpenseReason;
            vLCExpenseDetail.IsDeleted       = false;
            vLCExpenseDetail.CreatedBy       = vLCExpenseDetail.ModifiedBy = "Admin";
            vLCExpenseDetail.CreatedDate     = vLCExpenseDetail.ModifiedDate = DateTimeHelper.GetISTDateTime();
            vLCExpenseDetail.PaymentCrAmount = vLCExpenseDTO.PaymentCrAmount;
            vLCExpenseDetail.PaymentDrAmount = vLCExpenseDTO.PaymentDrAmount;
            vLCExpenseDetail.ExpenseComments = vLCExpenseDTO.ExpenseComments;

            if (vLCExpenseDetail.ExpenseDate != DateTime.MinValue)
            {
                vLCExpenseDetail.ExpenseDate = DateTimeHelper.GetISTDateTime().Date;
            }
            else
            {
                vLCExpenseDetail.ExpenseDate = vLCExpenseDTO.ExpenseDate.Value;
            }
            unitOfWork.VLCExpenseDetailRepository.Add(vLCExpenseDetail);
            if (vLCExpenseDTO.PaymentCrAmount > 0)
            {
                UpdateVLCWalletForExpense(vLCExpenseDTO.VLCId, vLCExpenseDTO.PaymentCrAmount, true);
                AddVLCExpenseInPaymentDetail(vLCExpenseDTO, vLCExpenseDetail.VLCExpenseId, vLCExpenseDTO.PaymentCrAmount);
            }
            else
            {
                UpdateVLCWalletForExpense(vLCExpenseDTO.VLCId, vLCExpenseDTO.PaymentDrAmount, false);
                AddVLCExpenseInPaymentDetail(vLCExpenseDTO, vLCExpenseDetail.VLCExpenseId, vLCExpenseDTO.PaymentCrAmount);
            }
            unitOfWork.SaveChanges();
            return(vLCExpenseDetail);
        }