Example #1
0
        public DTO.ModelDTO GetOverviewData(int id, int?offerSeasonDetailID, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ModelDTO Data = new DTO.ModelDTO();
            try
            {
                using (ProductOverviewRptEntities context = CreateContext())
                {
                    ProductOverviewRpt_Model_View dbItem = context.ProductOverviewRpt_Model_View
                                                           .Include("ProductOverviewRpt_PriceOverview_View")
                                                           .FirstOrDefault(o => o.ModelID == id);

                    if (dbItem == null)
                    {
                        throw new Exception("Model not found!");
                    }

                    DTO.ModelDTO data = converter.DB2DTO_Model(dbItem);

                    if (offerSeasonDetailID.HasValue)
                    {
                        var dbOfferDetail = context.ProductOverviewRpt_OfferSeasonDetail_View.Where(o => o.OfferSeasonDetailID == offerSeasonDetailID).FirstOrDefault();
                        if (dbOfferDetail != null)
                        {
                            data.ArticleCode = dbOfferDetail.ArticleCode;
                            data.Description = dbOfferDetail.Description;

                            data.PackagingMethodNM = dbOfferDetail.PackagingMethodNM;
                            data.ClientUD          = dbOfferDetail.ClientUD;
                            data.PurchasingPrice   = dbOfferDetail.PurchasingPrice;
                        }
                    }

                    return(data);
                }
            }
            catch (Exception ex)
            {
                ex = Library.Helper.GetInnerException(ex);
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }
            return(null);
        }
 public DTO.ModelDTO DB2DTO_Model(ProductOverviewRpt_Model_View dbItem)
 {
     return(AutoMapper.Mapper.Map <ProductOverviewRpt_Model_View, DTO.ModelDTO>(dbItem));
 }