public GetWOMasterForDcResponseDto GetWoMasterForDc(GetWOMasterForDcRequestDto getWOMasterForDcRequestDto)
        {
            GetWOMasterForDcResponseDto response;

            try
            {
                response = rDeliveryChallanProvider.GetWoMasterForDc(getWOMasterForDcRequestDto);
                response.ServiceResponseStatus = 1;
            }
            catch (SSException applicationException)
            {
                response = new GetWOMasterForDcResponseDto
                {
                    ServiceResponseStatus = 0,
                    ErrorMessage          = applicationException.Message,
                    ErrorCode             = applicationException.ExceptionCode
                };
            }
            catch (Exception exception)
            {
                response = new GetWOMasterForDcResponseDto
                {
                    ServiceResponseStatus = 0,
                    ErrorCode             = ExceptionAttributes.ExceptionCodes.InternalServerError,
                    ErrorMessage          = exception.Message
                };
            }

            return(response);
        }
        public GetWOMasterForDcResponseDto GetWoMasterForDc(GetWOMasterForDcRequestDto getWOMasterForDcRequestDto)
        {
            var response = new GetWOMasterForDcResponseDto()
            {
                getWOMasterForDcResponseList = new List <GetWOMasterForDcResponse>()
            };

            var model = deliveryChallanRepository.GetWoMasterAndDetails(getWOMasterForDcRequestDto.VendorCode, getWOMasterForDcRequestDto.WoType, getWOMasterForDcRequestDto.DcNumber, getWOMasterForDcRequestDto.Invoiced);


            foreach (var dcMasterDetails in model.getWoMasterAndDetailsFromCustomerCodeType)
            {
                var getsingle = new GetWOMasterForDcResponse
                {
                    getSerialNoFromWoNumerWoSerialResponseList = new List <GetSerialNoFromWoNumerWoSerialList>()
                };
                var getWoMasterDetailsResponse = new GetSerialNoFromWoNumerWoSerialList();
                getWoMasterDetailsResponse.SerialNo = dcMasterDetails.SerialNo;
                getWoMasterDetailsResponse.WONumber = dcMasterDetails.WONumber;
                getWoMasterDetailsResponse.WOSerial = dcMasterDetails.WOSerial;
                getWoMasterDetailsResponse.DCNumber = dcMasterDetails.DCNumber;
                getWoMasterDetailsResponse.IsNew    = dcMasterDetails.IsNew ? false : true;
                getWoMasterDetailsResponse.HeatNo   = dcMasterDetails.HeatNo;
                if (response.getWOMasterForDcResponseList.Count > 0)
                {
                    var isExist = response.getWOMasterForDcResponseList.Any(dcMaster => dcMaster.WONumber == dcMasterDetails.WONumber && dcMaster.WOSerial == dcMasterDetails.WOSerial);
                    if (isExist)
                    {
                        var index = response.getWOMasterForDcResponseList.FindIndex(a => a.WONumber == dcMasterDetails.WONumber && a.WOSerial == dcMasterDetails.WOSerial);

                        response.getWOMasterForDcResponseList[index].getSerialNoFromWoNumerWoSerialResponseList.Add(getWoMasterDetailsResponse);
                    }
                    else
                    {
                        getsingle.PartCode              = dcMasterDetails.PartCode;
                        getsingle.WONumber              = dcMasterDetails.WONumber;
                        getsingle.WOSerial              = dcMasterDetails.WOSerial;
                        getsingle.DCNumber              = dcMasterDetails.DCNumber;
                        getsingle.WOQuantity            = dcMasterDetails.WOQuantity;
                        getsingle.MaterialCode          = dcMasterDetails.MaterialCode;
                        getsingle.DrawingNumber         = dcMasterDetails.DrawingNumber;
                        getsingle.DrawingNumberRevision = dcMasterDetails.DrawingNumberRevision;
                        getsingle.HeatNo              = dcMasterDetails.HeatNo;
                        getsingle.WDCNumber           = dcMasterDetails.WDCNumber;
                        getsingle.ItemCode            = dcMasterDetails.ItemCode;
                        getsingle.PONumber            = dcMasterDetails.PONumber;
                        getsingle.PartDescription     = dcMasterDetails.PartDescription;
                        getsingle.MaterialDescription = dcMasterDetails.MaterialDescription;
                        getsingle.IsDeletable         = false;
                        getsingle.IsNew    = dcMasterDetails.IsNew ? false : true;
                        getsingle.DcSerial = dcMasterDetails.DcSerial;

                        //if (!dcMasterDetails.IsDelete)
                        //{
                        getsingle.getSerialNoFromWoNumerWoSerialResponseList.Add
                            (getWoMasterDetailsResponse);
                        //}

                        response.getWOMasterForDcResponseList.Add(getsingle);
                    }
                }
                else
                {
                    getsingle.PartCode              = dcMasterDetails.PartCode;
                    getsingle.WONumber              = dcMasterDetails.WONumber;
                    getsingle.WOSerial              = dcMasterDetails.WOSerial;
                    getsingle.DCNumber              = dcMasterDetails.DCNumber;
                    getsingle.WOQuantity            = dcMasterDetails.WOQuantity;
                    getsingle.MaterialCode          = dcMasterDetails.MaterialCode;
                    getsingle.ItemCode              = dcMasterDetails.ItemCode;
                    getsingle.PONumber              = dcMasterDetails.PONumber;
                    getsingle.PartDescription       = dcMasterDetails.PartDescription;
                    getsingle.DrawingNumber         = dcMasterDetails.DrawingNumber;
                    getsingle.DrawingNumberRevision = dcMasterDetails.DrawingNumberRevision;
                    getsingle.HeatNo              = dcMasterDetails.HeatNo;
                    getsingle.WDCNumber           = dcMasterDetails.WDCNumber;
                    getsingle.MaterialDescription = dcMasterDetails.MaterialDescription;
                    getsingle.IsDeletable         = false;
                    getsingle.IsNew    = dcMasterDetails.IsNew ? false : true;
                    getsingle.DcSerial = dcMasterDetails.DcSerial;
                    //if (!dcMasterDetails.IsDelete)
                    //{
                    getsingle.getSerialNoFromWoNumerWoSerialResponseList.Add
                        (getWoMasterDetailsResponse);
                    //}
                    response.getWOMasterForDcResponseList.Add(getsingle);
                }
            }

            //
            //if (getWOMasterForDcRequestDto.WoNumber == string.Empty && getWOMasterForDcRequestDto.WoSerial == 0)
            //{
            //    var model = deliveryChallanRepository.GetWoMasterForDc(getWOMasterForDcRequestDto.VendorCode, getWOMasterForDcRequestDto.WoType);

            //    if (model != null)
            //    {
            //        response = GetWoMasterForDcMapper((List<GetWOMasterForDcModel>)model.GetWOMasterForDcModelList, response);
            //    }
            //}
            //else
            //{
            //    var model = deliveryChallanRepository.GetSerialNoFromWoNumerWoSerialForDc(getWOMasterForDcRequestDto.WoNumber, getWOMasterForDcRequestDto.WoSerial);

            //    if (model != null)
            //    {
            //        response = GetWoMasterForDcMapper((List<GetSerialNoFromWoNumerWoSerialModel>)model.getSerialNoFromWoNumerWoSerialModel, response);
            //    }
            //}

            return(response);
        }
        private static GetWOMasterForDcResponseDto GetWoMasterForDcMapper(List <GetSerialNoFromWoNumerWoSerialModel> list, GetWOMasterForDcResponseDto getWOMasterForDcResponseDto)
        {
            //Mapper.CreateMap<GetSerialNoFromWoNumerWoSerialModel, GetSerialNoFromWoNumerWoSerialResponse>();
            //getWOMasterForDcResponseDto.getSerialNoFromWoNumerWoSerialResponseList =
            //    Mapper.Map<List<GetSerialNoFromWoNumerWoSerialModel>, List<GetSerialNoFromWoNumerWoSerialResponse>>(list);

            return(getWOMasterForDcResponseDto);
        }
        private static GetWOMasterForDcResponseDto GetWoMasterForDcMapper(List <GetWOMasterForDcModel> list, GetWOMasterForDcResponseDto getWOMasterForDcResponseDto)
        {
            //Mapper.CreateMap<GetWOMasterForDcModel, GetWOMasterForDcResponseList>();
            //getWOMasterForDcResponseDto.getWOMasterForDcResponseList =
            //    Mapper.Map<List<GetWOMasterForDcModel>, List<GetWOMasterForDcResponseList>>(list);

            return(getWOMasterForDcResponseDto);
        }