Пример #1
0
        public ActionResult Header()
        {
            var model = new HeaderViewModel()
            {
                CurrentUser = CurrentUser
            };

            var categoryList = metadataServiceClient.GetCategories(new MetaData.API.Models.Queries.Live.CategoryQuery()
            {
            }).Result;

            model.Categories = categoryList.Select(c => new CategoryViewModel().From(c)).ToList();

            if (CurrentUser != null)
            {
                var favitemCount = identityServiceClient.GetUsers(new Lidia.Identity.API.Models.Queries.UserQuery()
                {
                    RelatedUserIds = new List <int> {
                        CurrentUser.Id
                    }
                }).Result.FirstOrDefault().Properties.Where(k => k.Key == "FavProduct").Count();

                model.FavItemCount = favitemCount;
            }

            return(PartialView("_Header", model));
        }
Пример #2
0
        public JsonResult GetProductsByCategory([DataSourceRequest] DataSourceRequest req, int categoryId)
        {
            try
            {
                // Create the category query
                var categoryQuery = new CategoryQuery()
                {
                    CategoryIds = new List <int> {
                        categoryId
                    },
                    Envelope = "full"
                };

                var category = metadataServiceClient.GetCategories(categoryQuery).Result.FirstOrDefault();

                // Get all root categories
                var rootcategories = GetRootCategoriesFromCategories(category, new List <Category>());

                // Get the categoy ids
                var categoryids = rootcategories.Select(s => s.CategoryId).ToList();

                // Add selected category id to list
                categoryids.Add(categoryId);

                if (categoryids.Count != 0)
                {
                    // Create the product query
                    var productQuery = new ProductQuery()
                    {
                        CategoryIds = categoryids
                    };

                    // Get the products
                    var result = metadataServiceClient.GetProducts(productQuery);

                    // Set the data to model
                    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));
                }
                else
                {
                    return(Json(new ProductViewModel(), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
Пример #3
0
        public ActionResult List(int catId)
        {
            #region [ Breadcrumb ]

            // Create the breadcrumb
            var breadcrumb = new List <BreadcrumbItemViewModel>();
            breadcrumb.Add(new BreadcrumbItemViewModel()
            {
                Text = "Ürün Listesi" // degisecek
            });

            ViewBag.Breadcrumb = breadcrumb;

            #endregion

            var productList = metadataServiceClient.GetProducts(new MetaData.API.Models.Queries.Live.ProductQuery()
            {
                CategoryIds = new List <int> {
                    catId
                },
                Envelope = "full"
            }).Result;

            var categoryList = metadataServiceClient.GetCategories(new MetaData.API.Models.Queries.Live.CategoryQuery()
            {
                ProductIds = productList.Select(p => p.ProductId).ToList()
            }).Result;

            var model = new ProductListViewModel();

            model.Products = productList.Select(p => new ProductViewModel().From(p)).ToList();

            model.Categories = categoryList.Select(c => new CategoryViewModel().From(c)).ToList();

            return(View(model));
        }
Пример #4
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));
        }
Пример #5
0
        public ActionResult New()
        {
            var model = new CreateProductViewModel()
            {
                CurrentUser    = CurrentUser,
                TempPictureKey = CreateThreadId(5)
            };

            try
            {
                // Get the categories
                var categoryResponse = metadataServiceClient.GetCategories(new CategoryQuery()
                {
                    Envelope = "full"
                });

                if (CurrentUser.Status == Lidia.Identity.Common.Models.EntityStatus.Draft)
                {
                    model.Errors.Add("Üyeliğiniz henüz onaylanmamıştır. Üyeliğiniz onaylandığında size bilgi verilecektir.");

                    return(View(model));
                }

                // Get the trademarks
                var trademarks = metadataServiceClient.GetTrademarks(new TrademarkQuery());

                // Get the listing categories
                var categories = categoryResponse.Result.ToList();

                var parentList = new List <CategoryViewModel>();

                // Get parent list
                foreach (var category in categories)
                {
                    // Get the path
                    var idPath   = GetIDPath(category);
                    var namePath = GetNamePath(category);

                    parentList.Add(new CategoryViewModel()
                    {
                        CategoryId = category.CategoryId,
                        ParentId   = category.ParentId,
                        Parent     = category.Parent,
                        IdPath     = idPath,
                        NamePath   = namePath,
                        Name       = category.Name,
                        IsLeaf     = category.Children.Count == 0
                    });
                }

                // Set data to model
                model.Categories = parentList;
                model.Trademarks = trademarks.Result.ToList();
            }
            catch (Exception ex)
            {
                Log(Headstone.Framework.Models.LogMode.Error, "There is an error while creating the product", ex);
            }

            #region [ Breadcrumb ]

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

            breadcrumb.Add(new BreadcrumbItemViewModel()
            {
                Text = "Yeni"
            });

            ViewBag.Breadcrumb = breadcrumb;

            #endregion

            return(View(model));
        }
Пример #6
0
        public ActionResult Details(int id)
        {
            // Create the model
            var model = new CategoryDetailsViewModel();

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

                //Get the category
                var categoryResponse = _metadataServiceClient.GetCategories(query);

                //Check for errors
                if (categoryResponse.Errors.Any())
                {
                    categoryResponse.Errors.ForEach(error => model.Errors.Add(error));
                }

                var result = categoryResponse.Result.FirstOrDefault();

                model.Category = new CategoryViewModel()
                {
                    CategoryId       = result.CategoryId,
                    Name             = result.Name,
                    LongDescription  = result.LongDescription,
                    Type             = result.Type,
                    ParentId         = result.ParentId,
                    Code             = result.Code,
                    CRMCode          = result.CRMCode,
                    Status           = result.Status,
                    SortOrder        = result.SortOrder,
                    Products         = result.Products,
                    Children         = result.Children,
                    Parent           = result.Parent,
                    Properties       = result.Properties,
                    Tags             = result.Tags,
                    ShortDescription = result.ShortDescription,
                    Pictures         = result.Pictures
                };

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

                #region [ Breadcrumb ]

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

                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 category details! CategoryId:{id}", ex);
                model.Errors.Add(ex.Message);
                return(View(model));
            }
        }