public void UpdateSeller(Domain.Model.Seller inputSeller) { _logger.LogInformation($"Updating seller with ID {inputSeller.Id}"); Context.Seller currentEntity = _dbContext.Sellers.Find(inputSeller.Id); Context.Seller newEntity = Mapper.UnMapSeller(inputSeller); _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity); }
public Domain.Model.Seller GetSellerById(int sellerId) { _logger.LogInformation($"Retrieving seller id: {sellerId}"); Context.Seller returnSeller = _dbContext.Sellers .Include(p => p.Item) .Include(p => p.Review) .First(p => p.SellerId == sellerId); return(Mapper.MapSeller(returnSeller)); }
public void AddSeller(Domain.Model.Seller inputSeller) { if (inputSeller.Id != 0) { _logger.LogWarning($"Seller to be added has an ID ({inputSeller.Id}) already: ignoring."); } _logger.LogInformation("Adding seller"); Context.Seller entity = Mapper.UnMapSeller(inputSeller); entity.SellerId = 0; _dbContext.Add(entity); }
public void DeleteSellerById(int sellerId) { _logger.LogInformation($"Deleting seller with ID {sellerId}"); Context.Seller entity = _dbContext.Sellers.Find(sellerId); _dbContext.Remove(entity); }