Exemplo n.º 1
0
        public DTO.DocumentClientMng.DocumentClient DB2DTO_DocumentClient(DocumentClientMng_DocumentClient_View dbItem)
        {
            DTO.DocumentClientMng.DocumentClient dtoItem = AutoMapper.Mapper.Map <DocumentClientMng_DocumentClient_View, DTO.DocumentClientMng.DocumentClient>(dbItem);

            /*
             *  FORMAT FIELDS DATETIME
             */
            if (dbItem.DateEmailToClient.HasValue)
            {
                dtoItem.DateEmailToClientFormated = dbItem.DateEmailToClient.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.DateSendToClient.HasValue)
            {
                dtoItem.DateSendToClientFormated = dbItem.DateSendToClient.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.DateContainerDelivery.HasValue)
            {
                dtoItem.DateContainerDeliveryFormated = dbItem.DateContainerDelivery.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.TimeContainerDelivery.HasValue)
            {
                dtoItem.TimeContainerDeliveryFormated = dbItem.TimeContainerDelivery.Value.ToString("HH:mm");
            }

            if (dbItem.ETA.HasValue)
            {
                dtoItem.ETAFormated = dbItem.ETA.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.ETA2.HasValue)
            {
                dtoItem.ETA2Formated = dbItem.ETA2.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.CreatedDate.HasValue)
            {
                dtoItem.CreatedDateFormated = dbItem.CreatedDate.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.UpdatedDate.HasValue)
            {
                dtoItem.UpdatedDateFormated = dbItem.UpdatedDate.Value.ToString("dd/MM/yyyy");
            }

            if (dbItem.ConfirmedDateContainerDeliveryDate.HasValue)
            {
                dtoItem.ConfirmedDateContainerDeliveryDateFormated = dbItem.ConfirmedDateContainerDeliveryDate.Value.ToString("dd/MM/yyyy");
            }

            return(dtoItem);
        }
Exemplo n.º 2
0
        public DTO.DocumentClientMng.DataContainer GetDataContainer(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };

            //try to get data
            try
            {
                using (DocumentClientMngEntities context = CreateContext())
                {
                    DTO.DocumentClientMng.DataContainer dtoItem = new DTO.DocumentClientMng.DataContainer();

                    if (id > 0)
                    {
                        DocumentClientMng_DocumentClient_View dbItem = context.DocumentClientMng_DocumentClient_View
                                                                       .Include("DocumentClientMng_ECommercialInvoice_View")
                                                                       .FirstOrDefault(o => o.DocumentClientID == id);
                        DTO.DocumentClientMng.DocumentClient documentClientDTOItem = converter.DB2DTO_DocumentClient(dbItem);

                        //if (documentClientDTOItem.ConcurrencyFlag != null)
                        //{
                        //    documentClientDTOItem.ConcurrencyFlag_String = Convert.ToBase64String(documentClientDTOItem.ConcurrencyFlag);
                        //}

                        var dbOrder = context.DocumentClientMng_OrderInfo_View.Where(o => o.DocumentClientID != null && o.DocumentClientID == id).FirstOrDefault();
                        if (dbOrder != null)
                        {
                            documentClientDTOItem.ClientUD          = dbOrder.ClientUD;
                            documentClientDTOItem.ClientNM          = dbOrder.ClientNM;
                            documentClientDTOItem.ProformaInvoiceNo = dbOrder.ProformaInvoiceNo;
                        }
                        dtoItem.DocumentClientData = documentClientDTOItem;
                    }
                    else
                    {
                        dtoItem.DocumentClientData = new DTO.DocumentClientMng.DocumentClient();
                    }

                    // get support data
                    dtoItem.TypeOfDeliverys  = converter.DB2DTO_TypeOfDeliverys(context.TypeOfDelivery.ToList());
                    dtoItem.PlaceOfBarges    = converter.DB2DTO_PlaceOfBarges(context.PlaceOfBarge.ToList());
                    dtoItem.PlaceOfDeliverys = converter.DB2DTO_PlaceOfDeliverys(context.PlaceOfDelivery.ToList());
                    dtoItem.DeliveryStatuss  = converter.DB2DTO_DeliveryStatuss(context.DeliveryStatus.ToList());
                    dtoItem.PaymentStatuss   = converter.DB2DTO_PaymentStatuss(context.PaymentStatus.ToList());
                    dtoItem.Seasons          = new DAL.Support.DataFactory().GetSeason().ToList();
                    dtoItem.ReportTemplates  = new DAL.Support.DataFactory().GetReportTemplate().ToList();

                    return(dtoItem);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(new DTO.DocumentClientMng.DataContainer());
            }
        }