public void Update(VLCMilkCollectionDtl vlcMilkCollectionDtl)
 {
     if (vlcMilkCollectionDtl != null)
     {
         _repository.Entry <Sql.VLCMilkCollectionDtl>(vlcMilkCollectionDtl).State = System.Data.Entity.EntityState.Modified;
         //  _repository.SaveChanges();
     }
 }
 public void Add(VLCMilkCollectionDtl vlcMilkCollectionDtl)
 {
     if (vlcMilkCollectionDtl != null)
     {
         _repository.VLCMilkCollectionDtls.Add(vlcMilkCollectionDtl);
         // _repository.SaveChanges();
     }
 }
예제 #3
0
        public static VLCCustomerCollectionDtlDTO ConvertToCustomerCollectionDtlDTO(VLCMilkCollectionDtl vLCMilkCollectionDtl)
        {
            VLCCustomerCollectionDtlDTO vLCCustomerCollectionDtlDTO = new VLCCustomerCollectionDtlDTO();

            vLCCustomerCollectionDtlDTO.VLCMilkCollectionDtlId = vLCMilkCollectionDtl.VLCMilkCollectionDtlId;
            vLCCustomerCollectionDtlDTO.CLR         = vLCMilkCollectionDtl.CLR.GetValueOrDefault();
            vLCCustomerCollectionDtlDTO.Fat         = vLCMilkCollectionDtl.FAT.GetValueOrDefault();
            vLCCustomerCollectionDtlDTO.Quantity    = vLCMilkCollectionDtl.Qunatity.GetValueOrDefault();
            vLCCustomerCollectionDtlDTO.Amount      = vLCMilkCollectionDtl.Amount.GetValueOrDefault();
            vLCCustomerCollectionDtlDTO.ProductName = vLCMilkCollectionDtl.ProductId == 1 ? "Cow Milk" : "Buffalo Milk";
            return(vLCCustomerCollectionDtlDTO);
        }
예제 #4
0
 public static void ConvertToVLCMilkCollectionDtlEntity(ref VLCMilkCollectionDtl vlcMilkCollectionDtl, VLCMilkCollectionDtlDTO vlcMilkCollectionDtlDTO, bool isUpdate)
 {
     if (isUpdate)
     {
         vlcMilkCollectionDtl.VLCMilkCollectionDtlId = vlcMilkCollectionDtlDTO.VLCMilkCollectionDtlId;
     }
     vlcMilkCollectionDtl.CLR         = vlcMilkCollectionDtlDTO.CLR;
     vlcMilkCollectionDtl.FAT         = vlcMilkCollectionDtlDTO.FAT;
     vlcMilkCollectionDtl.Qunatity    = vlcMilkCollectionDtlDTO.Quantity;
     vlcMilkCollectionDtl.RatePerUnit = vlcMilkCollectionDtlDTO.RatePerUnit;
     vlcMilkCollectionDtl.Amount      = vlcMilkCollectionDtlDTO.Amount;
     vlcMilkCollectionDtl.ProductId   = (int)vlcMilkCollectionDtlDTO.ProductId;
 }
예제 #5
0
        public static VLCMilkCollectionDtlDTO ConvertToVLCMilkCollectionDetailDTO(VLCMilkCollectionDtl vLCMilkCollectionDtl)
        {
            VLCMilkCollectionDtlDTO vLCMilkCollectionDtlDTO = new VLCMilkCollectionDtlDTO();

            vLCMilkCollectionDtlDTO.Amount = vLCMilkCollectionDtl.Amount;
            vLCMilkCollectionDtlDTO.CLR    = vLCMilkCollectionDtl.CLR;
            vLCMilkCollectionDtlDTO.FAT    = vLCMilkCollectionDtl.FAT;
            MilkTypeEnum milkType;

            Enum.TryParse <MilkTypeEnum>(vLCMilkCollectionDtl.ProductId.ToString(), out milkType);
            vLCMilkCollectionDtlDTO.ProductId           = milkType;
            vLCMilkCollectionDtlDTO.ProductName         = milkType.ToString();
            vLCMilkCollectionDtlDTO.Quantity            = vLCMilkCollectionDtl.Qunatity;
            vLCMilkCollectionDtlDTO.RatePerUnit         = vLCMilkCollectionDtl.RatePerUnit;
            vLCMilkCollectionDtlDTO.VLCMilkCollectionId = vLCMilkCollectionDtl.VLCMilkCollectionId;
            return(vLCMilkCollectionDtlDTO);
        }
예제 #6
0
        public ResponseDTO AddVLCMilkCollection(VLCMilkCollectionDTO vLCMilkCollectionDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            //  this.CheckForExisitngCustomer(vlcDto.MobileNumber);
            VLCMilkCollection vLCMilkCollection = new VLCMilkCollection();

            vLCMilkCollection.VLCMilkCollectionId = unitOfWork.DashboardRepository.NextNumberGenerator("VLCMilkCollection");
            vLCMilkCollection.CollectionDateTime  = DateTimeHelper.GetISTDateTime();
            vLCMilkCollection.CreatedDate         = DateTimeHelper.GetISTDateTime();
            vLCMilkCollection.ModifiedDate        = DateTimeHelper.GetISTDateTime();
            vLCMilkCollection.CreatedBy           = vLCMilkCollectionDTO.ModifiedBy = "Admin";
            vLCMilkCollection.IsDeleted           = false;
            VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionEntity(ref vLCMilkCollection, vLCMilkCollectionDTO, false);
            if (vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList != null)
            {
                foreach (var vlcCollectionDtlDTO in vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList)
                {
                    this.CheckForExistingCollectionDetailByDateShiftProduct(vLCMilkCollection.CollectionDateTime.Value.Date, vLCMilkCollectionDTO.ShiftId, vlcCollectionDtlDTO.ProductId, vLCMilkCollectionDTO.CustomerId);
                    VLCMilkCollectionDtl vLCMilkCollectionDtl = new VLCMilkCollectionDtl();
                    vLCMilkCollectionDtl.VLCMilkCollectionDtlId = unitOfWork.DashboardRepository.NextNumberGenerator("VLCMilkCollectionDtl");
                    vLCMilkCollectionDtl.VLCMilkCollectionId    = vLCMilkCollection.VLCMilkCollectionId;
                    VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionDtlEntity(ref vLCMilkCollectionDtl, vlcCollectionDtlDTO, false);
                    unitOfWork.VLCMilkCollectionDtlRepository.Add(vLCMilkCollectionDtl);
                }

                vLCMilkCollection.TotalAmount   = vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList.Sum(s => s.Amount);
                vLCMilkCollection.TotalQuantity = vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList.Sum(s => s.Quantity);
            }
            else
            {
                throw new PlatformModuleException("Milk Collection Detail Not Found");
            }
            unitOfWork.VLCMilkCollectionRepository.Add(vLCMilkCollection);

            unitOfWork.SaveChanges();
            responseDTO.Status  = true;
            responseDTO.Message = String.Format("Milk Collection Detail Added Successfully ");
            responseDTO.Data    = this.GetVLCCustomerCollectionByDateAndShift(vLCMilkCollectionDTO.VLCId, DateTimeHelper.GetISTDateTime().Date, vLCMilkCollectionDTO.ShiftId, 1);

            return(responseDTO);
        }
예제 #7
0
        public ResponseDTO UpdateVLCMilkCollection(VLCMilkCollectionDTO vLCMilkCollectionDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            //Will update the method when required
            var vlcMilkCollection = unitOfWork.VLCMilkCollectionRepository.GetById(vLCMilkCollectionDTO.VLCMilkCollectionId);

            //TODO: Make sure what detail need to allow for update - Anil
            vlcMilkCollection.ShiftId            = (int)vLCMilkCollectionDTO.ShiftId;
            vlcMilkCollection.CollectionDateTime = vLCMilkCollectionDTO.CollectionDateTime;
            vlcMilkCollection.CustomerId         = vLCMilkCollectionDTO.CustomerId;
            vlcMilkCollection.VLCId = vLCMilkCollectionDTO.VLCId;

            var customer = unitOfWork.CustomerRepository.GetById(vlcMilkCollection.CustomerId.GetValueOrDefault());

            if (vlcMilkCollection == null)
            {
                throw new PlatformModuleException(string.Format("VLC Milk Collection Detail Not Found with Collection Id {0}", vLCMilkCollectionDTO.VLCMilkCollectionId));
            }
            vlcMilkCollection.ModifiedDate = DateTimeHelper.GetISTDateTime();
            vlcMilkCollection.ModifiedBy   = "Admin";
            //    VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionEntity(ref vlcMilkCollection, vLCMilkCollectionDTO, true);

            var detailList = unitOfWork.VLCMilkCollectionDtlRepository.GetById(vLCMilkCollectionDTO.VLCMilkCollectionId);

            if (detailList != null && detailList.Count() > 0)
            {
                foreach (var collectionDtl in detailList)
                {
                    unitOfWork.VLCMilkCollectionDtlRepository.Delete(collectionDtl.VLCMilkCollectionDtlId);
                }
            }

            if (vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList != null)
            {
                foreach (var vlcCollectionDtlDTO in vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList)
                {
                    VLCMilkCollectionDtl vLCMilkCollectionDtl = new VLCMilkCollectionDtl();
                    vLCMilkCollectionDtl.VLCMilkCollectionDtlId = unitOfWork.DashboardRepository.NextNumberGenerator("VLCMilkCollectionDtl");
                    vLCMilkCollectionDtl.VLCMilkCollectionId    = vlcMilkCollection.VLCMilkCollectionId;
                    VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionDtlEntity(ref vLCMilkCollectionDtl, vlcCollectionDtlDTO, false);
                    //vLCMilkCollectionDtl.RatePerUnit = unitOfWork.MilkRateRepository.GetMilkRateByApplicableRate(customer.ApplicableRate, vlcCollectionDtlDTO.FAT.GetValueOrDefault(), vlcCollectionDtlDTO.CLR.GetValueOrDefault());
                    //vlcCollectionDtlDTO.Amount = vLCMilkCollectionDtl.Amount = vLCMilkCollectionDtl.RatePerUnit * vLCMilkCollectionDtl.Qunatity;

                    unitOfWork.VLCMilkCollectionDtlRepository.Add(vLCMilkCollectionDtl);
                }

                vlcMilkCollection.TotalAmount   = vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList.Sum(s => s.Amount);
                vlcMilkCollection.TotalQuantity = vLCMilkCollectionDTO.vLCMilkCollectionDtlDTOList.Sum(s => s.Quantity);
            }
            else
            {
                throw new PlatformModuleException("VLC Milk Collection Details Not Found");
            }

            unitOfWork.VLCMilkCollectionRepository.Update(vlcMilkCollection);
            unitOfWork.SaveChanges();
            responseDTO.Status  = true;
            responseDTO.Message = String.Format("Milk Collection Detail Updated Successfully");
            ShiftEnum shift;

            Enum.TryParse <ShiftEnum>(vlcMilkCollection.ShiftId.GetValueOrDefault().ToString(), out shift);
            responseDTO.Data = this.GetVLCCustomerCollectionByDateAndShift(vlcMilkCollection.VLCId.GetValueOrDefault(), DateTimeHelper.GetISTDateTime().Date, shift, 1);
            return(responseDTO);
        }