Exemplo n.º 1
0
        public JsonResult GetTrademarks([DataSourceRequest] DataSourceRequest req)
        {
            try
            {
                var query = new TrademarkQuery();

                var result   = _metadataServiceClient.GetTrademarks(query);
                var response = result.Result.Select(r => new TrademarkViewModel
                {
                    TrademarkId      = r.TrademarkId,
                    Name             = r.Name,
                    ShortDescription = r.ShortDescription,
                    LongDescription  = r.LongDescription,
                    Code             = r.Code,
                    ERPCode          = r.ERPCode,
                    Products         = r.Products
                }).ToList().OrderByDescending(i => i.TrademarkId).ToDataSourceResult(req);

                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, $"There is an error while getting the trademark data!", ex);

                return(Json(ex));
            }
        }
Exemplo n.º 2
0
        public JsonResult GetProductsByTrademark([DataSourceRequest] DataSourceRequest req, int trademarkId)
        {
            try
            {
                var query = new TrademarkQuery
                {
                    TrademarkIds = new List <int> {
                        trademarkId
                    },
                    Envelope = "full"
                };
                var trademarkResult = metadataServiceClient.GetTrademarks(query).Result.FirstOrDefault();

                var productIds = trademarkResult.Products.Select(p => p.ProductId).ToList();

                if (productIds.Count <= 0)
                {
                    return(Json(new ProductViewModel(), JsonRequestBehavior.AllowGet));
                }

                var productQuery = new ProductQuery
                {
                    ProductIds = productIds
                };

                var result   = metadataServiceClient.GetProducts(productQuery);
                var response = result.Result.Select(r => new ProductViewModel
                {
                    ProductId        = r.ProductId,
                    Name             = r.Name,
                    ShortDescription = r.ShortDescription
                }).ToList().OrderByDescending(i => i.ProductId).ToDataSourceResult(req);

                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
Exemplo n.º 3
0
        public ActionResult CustomerReviewDetails(int id)
        {
            // Create the model
            var model = new CustomerReviewDetailsViewModel();

            try
            {
                // Create the comment query
                var request = new CommentRequest()
                {
                    CommentIds = new List <int> {
                        id
                    }
                };

                // Get the comment
                var response = _commentService.GetComments(request).Result.FirstOrDefault();

                // Set the comment data
                model.CustomerReview = new CustomerReviewViewModel
                {
                    Body                  = response.Body,
                    CommentId             = response.CommentId,
                    Created               = response.Created.ToString("dd-MM-yyyy HH:mm"),
                    Status                = response.Status,
                    ParentId              = response.ParentId,
                    Rating                = response.Rating,
                    RelatedDataEntityId   = response.RelatedDataEntityId,
                    RelatedDataEntityType = response.RelatedDataEntityType,
                    Type                  = response.Type,
                    Updated               = response.Updated,
                    UserId                = response.UserId
                };

                #region [ User ]

                // Create the user query
                var userQuery = new UserQuery()
                {
                    RelatedUserIds = new List <int> {
                        response.UserId
                    }
                };

                // Get the user
                var userResponse = _identityService.GetUsers(userQuery).Result.FirstOrDefault();

                // Set the source username
                model.SourceUserName = userResponse.Firstname + " " + userResponse.Lastname;

                #endregion

                #region [ Related Entity ]

                switch (response.RelatedDataEntityType)
                {
                case "Product":

                    // Create the product query
                    var productQuery = new ProductQuery()
                    {
                        ProductIds = new List <int> {
                            response.RelatedDataEntityId
                        },
                        Envelope = "full"
                    };

                    // Get the product
                    var product = _metadataServiceClient.GetProducts(productQuery).Result.FirstOrDefault();

                    // Set the related data
                    model.Description = product.ShortDescription;
                    model.SourceId    = product.ProductId;
                    model.SourceTitle = product.Name;
                    model.Created     = product.Created.ToString("yyyy-MM-dd HH:mm");
                    model.Images      = product.Pictures.Select(p => p.ImageUrl).ToList();
                    break;

                case "Trademark":

                    // Create the trademark query
                    var trademarkQuery = new TrademarkQuery()
                    {
                        TrademarkIds = new List <int> {
                            response.RelatedDataEntityId
                        },
                        Envelope = "full"
                    };

                    // Get the trademark
                    var trademark = _metadataServiceClient.GetTrademarks(trademarkQuery).Result.FirstOrDefault();

                    // Set the related data
                    model.Description = trademark.ShortDescription;
                    model.SourceId    = trademark.TrademarkId;
                    model.SourceTitle = trademark.Name;
                    model.Created     = trademark.Created.ToString("yyyy-MM-dd HH:mm");
                    model.Images      = trademark.Pictures.Select(p => p.ImageUrl).ToList();
                    break;

                case "Category":

                    // Create the category query
                    var categoryQuery = new CategoryQuery()
                    {
                        CategoryIds = new List <int> {
                            response.RelatedDataEntityId
                        },
                        Envelope = "full"
                    };

                    // Get the category
                    var category = _metadataServiceClient.GetCategories(categoryQuery).Result.FirstOrDefault();

                    // Set the related data
                    model.Description = category.ShortDescription;
                    model.SourceId    = category.CategoryId;
                    model.SourceTitle = category.Name;
                    model.Created     = category.Created.ToString("yyyy-MM-dd HH:mm");
                    break;
                }

                #endregion

                #region [ Breadcrumb ]

                // Create the breadcrumb
                var breadcrumb = new List <BreadcrumbItemViewModel>();
                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Yorumlar Ve Puanlar",
                    Link = "/contents/customerreviews"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = response.CommentId.ToString()
                });

                ViewBag.Breadcrumb = breadcrumb;

                #endregion
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, $"There is an error while getting the customer review details! CustomerReviewId:{id}", ex);
            }
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Details(int id)
        {
            var model = new TrademarkDetailsViewModel();

            try
            {
                // Create the query
                var query = new TrademarkQuery
                {
                    TrademarkIds = new List <int> {
                        id
                    },
                    Envelope = "full"
                };

                // Get the category
                var result = _metadataServiceClient.GetTrademarks(query).Result.FirstOrDefault();

                model.Trademark = new TrademarkViewModel
                {
                    TrademarkId = result.TrademarkId,
                    Name        = result.Name,
                    Parent      = _metadataServiceClient.GetTrademarks(new TrademarkQuery
                    {
                        TrademarkIds = new List <int> {
                            result.ParentId
                        },
                        Envelope = "full"
                    }).Result.FirstOrDefault(),
                    Children         = result.Children,
                    LongDescription  = result.LongDescription,
                    ShortDescription = result.ShortDescription,
                    Code             = result.Code,
                    ERPCode          = result.ERPCode,
                    Products         = result.Products,
                    Properties       = result.Properties,
                    Status           = result.Status,
                    Tags             = result.Tags,
                    Pictures         = result.Pictures
                };

                model.Trademark = this.CreateSelectLists(model.Trademark);

                // Get the products
                var productIds = new List <int>();

                // Create the product query
                var productQuery = new ProductQuery()
                {
                    TrademarkIds = new List <int> {
                        id
                    }
                };

                // Get the products
                model.Products = _metadataServiceClient.GetProducts(productQuery).Result;

                #region [ Breadcrumb ]

                // Create the breadcrumb
                var breadcrumb = new List <BreadcrumbItemViewModel>();
                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Markalar",
                    Link = "/trademarks"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = result.Name
                });

                ViewBag.Breadcrumb = breadcrumb;

                #endregion

                return(View(model));
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, $"There is an error while getting the trademark details! TrademarkId:{id}", ex);

                return(View());
            }
        }
Exemplo n.º 5
0
        public ActionResult Details(int id)
        {
            var model = new ProductViewModel();

            try
            {
                #region [ Category ]

                var categoryQuery = new CategoryQuery
                {
                    ProductIds = new List <int> {
                        id
                    },
                    Envelope = "full"
                };

                // Get the category
                var categoryResult = metadataServiceClient.GetCategories(categoryQuery).Result;

                //Set category
                model.Categories = categoryResult;

                #endregion

                #region [ Trademark ]

                var trademarkQuery = new TrademarkQuery
                {
                    ProductIds = new List <int> {
                        id
                    },
                    Envelope = "full"
                };

                // Get the trademark
                var trademarkResult = metadataServiceClient.GetTrademarks(trademarkQuery).Result;
                //Set trademark
                model.Trademarks = trademarkResult;

                #endregion

                #region [ Product ]

                // Create the query
                var query = new ProductQuery
                {
                    ProductIds = new List <int> {
                        id
                    },
                    Envelope = "full"
                };

                var result = metadataServiceClient.GetProducts(query).Result.FirstOrDefault();

                // Get the products
                model.Product    = result;
                model.Categories = result.CategoryProducts.Select(a => a.Category).ToList();
                model.Trademarks = result.TrademarkProducts.Select(a => a.Trademark).ToList();

                #endregion

                #region [ Breadcrumb ]

                // Create the breadcrumb
                var breadcrumb = new List <BreadcrumbItemViewModel>();
                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Ürünler",
                    Link = "/products"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = result.Name
                });

                ViewBag.Breadcrumb = breadcrumb;

                #endregion
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, $"There is an error while getting the product details! ProductId:{id}", ex);

                return(View());
            }
            return(View(model));
        }