Example #1
0
        public IHttpActionResult Get(int id)
        {
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanRead))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.DocumentClientMng               bll = new BLL.DocumentClientMng();
            Library.DTO.Notification            notification;
            DTO.DocumentClientMng.DataContainer DocumentClient = bll.GetDataContainer(id, ControllerContext.GetAuthUserId(), out notification);

            return(Ok(new Library.DTO.ReturnData <DTO.DocumentClientMng.DataContainer>()
            {
                Data = DocumentClient, Message = notification
            }));
        }
Example #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());
            }
        }