public IEnumerable <Showroom> GetAll() { List <Showroom> Showrooms = new List <Showroom>(); foreach (Showroom OneShowroom in _repository.GetAll()) { Showroom NewShowroom = new Showroom(); NewShowroom = OneShowroom; NewShowroom.Showroomer = null; NewShowroom.Product = null; Showrooms.Add(NewShowroom); } return(Showrooms); }
public IActionResult Get() { StringValues hearderValues; var firstValue = string.Empty; if (Request.Headers.TryGetValue("id", out hearderValues)) { firstValue = hearderValues.FirstOrDefault(); } long id = Convert.ToInt64(firstValue); var item = _repository.Find(id); if (item == null) { return(NotFound()); } #region Interactions List // Rate list for the user that he commented for this product List <Interaction> InteractionList = new List <Interaction>(); var InteractionQuery = from interaction in _interactionRepository.GetAll() where interaction.UserId == item.UserId select interaction; foreach (var interaction in InteractionQuery) { Interaction UserRate = new Interaction(); UserRate = interaction; UserRate.User = null; UserRate.Product = null; InteractionList.Add(UserRate); } item.Interactions = InteractionList; #endregion #region Vouchers List // Vouchers List var Query = from voucher in _voucherRepository.GetAll() where voucher.UserId == item.UserId select voucher; List <Voucher> VoucherList = new List <Voucher>(); foreach (var voucher in Query) { Voucher v = new Voucher(); v = voucher; v.User = null; VoucherList.Add(v); } item.Vouchers = VoucherList; // End Vouchers List #endregion #region Showrooms List // Rate list for the user that he commented for this product List <Showroom> ShowroomList = new List <Showroom>(); var ShowroomQuery = from showroom in _showroomRepository.GetAll() where showroom.ShowroomerId == item.UserId select showroom; foreach (var showroom in ShowroomQuery) { Showroom UserShowroom = new Showroom(); UserShowroom = showroom; // Product that this user accept to be showroom var ProductQuery = from product in _productRepository.GetAll() where product.ProductId == showroom.ProductId select product; if (ProductQuery == null) { UserShowroom.Product = null; } else { Product NewProduct = new Product(); var OldProduct = ProductQuery.First(); NewProduct = OldProduct; NewProduct.Images = null; NewProduct.Interactions = null; NewProduct.Orders = null; NewProduct.Showrooms = null; UserShowroom.Product = NewProduct; } UserShowroom.Showroomer = null; ShowroomList.Add(UserShowroom); } item.Showrooms = ShowroomList; #endregion // Unset variables that are unused InteractionList = null; InteractionQuery = null; VoucherList = null; Query = null; ShowroomList = null; ShowroomQuery = null; return(new ObjectResult(item)); }
public IActionResult Get() { StringValues hearderValues; var firstValue = string.Empty; if (Request.Headers.TryGetValue("id", out hearderValues)) { firstValue = hearderValues.FirstOrDefault(); } long id = Convert.ToInt64(firstValue); var item = _repository.Find(id); if (item == null) { return(NotFound()); } #region Interactions List // Rate list for the user that he commented for this product List <Interaction> InteractionList = new List <Interaction>(); var InteractionQuery = from interaction in _interactionRepository.GetAll() where interaction.ProductId == item.ProductId select interaction; foreach (var interaction in InteractionQuery) { Interaction UserRate = new Interaction(); UserRate = interaction; UserRate.User = null; UserRate.Product = null; InteractionList.Add(UserRate); } item.Interactions = InteractionList; #endregion #region Showrooms List List <Showroom> ShowroomsList = new List <Showroom>(); var ShowroomQuery = from showroom in _showroomRepository.GetAll() where showroom.ProductId == item.ProductId select showroom; foreach (var showroom in ShowroomQuery) { Showroom showrooms = new Showroom(); showrooms = showroom; showrooms.Product = null; showrooms.Showroomer = null; ShowroomsList.Add(showrooms); } item.Showrooms = ShowroomsList; #endregion #region Images List List <Image> ImagesList = new List <Image>(); var ImageQuery = from image in _imageRepository.GetAll() where image.ProductId == item.ProductId select image; foreach (var image in ImageQuery) { Image images = new Image(); images = image; images.Product = null; ImagesList.Add(images); } item.Images = ImagesList; #endregion // Unset variables that are unused InteractionList = null; InteractionQuery = null; ShowroomsList = null; ShowroomQuery = null; ImagesList = null; ImageQuery = null; return(new ObjectResult(item)); }