public IActionResult Update([FromBody] Showroomer item) { StringValues hearderValues; var firstValue = string.Empty; if (Request.Headers.TryGetValue("id", out hearderValues)) { firstValue = hearderValues.FirstOrDefault(); } long id = Convert.ToInt64(firstValue); if (item == null || item.UserId != id) { return(BadRequest()); } var Showroomer = _repository.Find(id); if (Showroomer == null) { return(NotFound()); } Showroomer.City = item.City; Showroomer.Description = item.Description; Showroomer.Latitude = item.Latitude; Showroomer.Longitude = item.Longitude; Showroomer.Street = item.Street; Showroomer.Username = item.Username; Showroomer.ZipCode = item.ZipCode; _repository.Update(Showroomer); return(new NoContentResult()); }
public IActionResult Create([FromBody] Showroomer value) { if (value == null) { return(BadRequest()); } _repository.Add(value); return(new NoContentResult()); }
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()); } var SelectedUser = _showroomerRepository.Find(item.ShowroomerId); Showroomer showroomer = new Showroomer(); showroomer = SelectedUser; showroomer.Showrooms = null; showroomer.Orders = null; showroomer.Vouchers = null; showroomer.Interactions = null; item.Showroomer = showroomer; var SelectedProduct = _productRepository.Find(item.ProductId); Product Product = new Product(); Product = SelectedProduct; Product.Showrooms = null; Product.Interactions = null; Product.Orders = null; Product.Images = null; item.Product = Product; // Unset variables that are unused SelectedUser = null; showroomer = null; SelectedProduct = null; Product = null; return(new ObjectResult(item)); }
public IEnumerable <Showroomer> GetAll() { List <Showroomer> ListShowroomer = new List <Showroomer>(); foreach (Showroomer ShowroomerOne in _repository.GetAll()) { Showroomer NewShowroomer = new Showroomer(); NewShowroomer = ShowroomerOne; NewShowroomer.Vouchers = null; NewShowroomer.Showrooms = null; NewShowroomer.Orders = null; NewShowroomer.Interactions = null; ListShowroomer.Add(NewShowroomer); } return(ListShowroomer); }
public IEnumerable <Voucher> GetAll() { List <Voucher> ListVoucher = new List <Voucher>(); foreach (Voucher VoucherOne in _repository.GetAll()) { Voucher NewVoucher = new Voucher(); NewVoucher = VoucherOne; Showroomer UpdatedUser = new Showroomer(); var OldUser = _showroomerRepository.Find(VoucherOne.UserId); UpdatedUser = OldUser; UpdatedUser.Vouchers = null; UpdatedUser.Showrooms = null; UpdatedUser.Orders = null; UpdatedUser.Interactions = null; NewVoucher.User = UpdatedUser; ListVoucher.Add(NewVoucher); } return(ListVoucher); }
public void Update(Showroomer item) { _context.Showroomers.Update(item); _context.SaveChanges(); }
public void Add(Showroomer item) { _context.Showroomers.Add(item); _context.SaveChanges(); }