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)); } }
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)); }
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()); } }
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)); }