public VLCMilkCollectionDTO GetVLCMilkCollectionById(int vlcMilkCollectionId) { VLCMilkCollectionDTO vlcMilkCollectionDto = null; var vlcMilkCollection = unitOfWork.VLCMilkCollectionRepository.GetById(vlcMilkCollectionId); if (vlcMilkCollection != null) { vlcMilkCollectionDto = VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionDto(vlcMilkCollection); } return(vlcMilkCollectionDto); }
public List <VLCMilkCollectionDTO> GetAllVLCMilkCollectionByPageCount(int?pageNumber, int?count) { List <VLCMilkCollectionDTO> vlcMilkCollectionList = new List <VLCMilkCollectionDTO>(); var vLCMilkCollections = unitOfWork.VLCMilkCollectionRepository.GetVLCMilkCollectionByCount(pageNumber, count); if (vLCMilkCollections != null) { foreach (var vlc in vLCMilkCollections) { vlcMilkCollectionList.Add(VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionDto(vlc)); } } return(vlcMilkCollectionList); }
public List <VLCMilkCollectionDTO> GetAllVLCMilkCollection() { List <VLCMilkCollectionDTO> vlcMilkCollectionList = new List <VLCMilkCollectionDTO>(); var vLCMilkCollections = unitOfWork.VLCMilkCollectionRepository.GetAll(); if (vLCMilkCollections != null) { foreach (var vlcMilkCollection in vLCMilkCollections) { vlcMilkCollectionList.Add(VLCMilkCollectionConvertor.ConvertToVLCMilkCollectionDto(vlcMilkCollection)); } } return(vlcMilkCollectionList); }
public List <VLCCustomerCollectionDTO> GetVLCCustomerCollectionByDateAndShift(int vlcId, DateTime collectionDate, ShiftEnum shift, int?pageNumber) { List <VLCCustomerCollectionDTO> vlcCustomerMilkCollection = new List <VLCCustomerCollectionDTO>(); var vLCMilkCollection = unitOfWork.VLCMilkCollectionRepository.GetByVLCIdAndCollectionDateShift(vlcId, collectionDate, shift, pageNumber); if (vLCMilkCollection != null) { foreach (var vlcMilk in vLCMilkCollection) { vlcCustomerMilkCollection.Add(VLCMilkCollectionConvertor.ConvertToVLCCustomerCollectionDTO(vlcMilk)); } } return(vlcCustomerMilkCollection); }
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); }
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); }