public void UpdateStore(Domain.Model.Store inputStore) { _logger.LogInformation($"Updating store with ID {inputStore.Id}"); Context.Store currentEntity = _dbContext.Stores.Find(inputStore.Id); Context.Store newEntity = Mapper.UnMapStore(inputStore); _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity); }
public Domain.Model.Store GetStoreById(int storeId) { _logger.LogInformation($"Retrieving store id: {storeId}"); Context.Store returnStore = _dbContext.Stores .Include(p => p.Item) .Include(p => p.Person) .First(p => p.StoreId == storeId); return(Mapper.MapStore(returnStore)); }
public void AddStore(Domain.Model.Store inputStore) { if (inputStore.Id != 0) { _logger.LogWarning($"Store to be added has an ID ({inputStore.Id}) already: ignoring."); } _logger.LogInformation("Adding store"); Context.Store entity = Mapper.UnMapStore(inputStore); entity.StoreId = 0; _dbContext.Add(entity); }
public void DeleteStoreById(int storeId) { _logger.LogInformation($"Deleting store with ID {storeId}"); Context.Store entity = _dbContext.Stores.Find(storeId); _dbContext.Remove(entity); }