public void AddPerson(Domain.Model.Person inputPerson) { if (inputPerson.Id != 0) { _logger.LogWarning($"Person to be added has an ID ({inputPerson.Id}) already: ignoring."); } _logger.LogInformation("Adding person"); Context.Person entity = Mapper.UnMapPerson(inputPerson); entity.PersonId = 0; _dbContext.Add(entity); }
public void AddReview(Domain.Model.Review inputReview) { if (inputReview.Id != 0) { _logger.LogWarning($"Review to be added has an ID ({inputReview.Id}) already: ignoring."); } _logger.LogInformation("Adding review"); Context.Review entity = Mapper.UnMapReview(inputReview); entity.ReviewId = 0; _dbContext.Add(entity); }
public void AddTopic(Domain.Model.TopicOption inputTopic) { if (inputTopic.Id != 0) { _logger.LogWarning($"Topic to be added has an ID ({inputTopic.Id}) already: ignoring."); } _logger.LogInformation("Adding topic"); Context.TopicOption entity = Mapper.UnMapTopic(inputTopic); entity.TopicOptionId = 0; _dbContext.Add(entity); }
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 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 AddItem(Domain.Model.Item inputItem) { if (inputItem.Id != 0) { _logger.LogWarning($"Item to be added has an ID ({inputItem.Id}) already: ignoring."); } _logger.LogInformation("Adding item"); Context.Item entity = Mapper.UnMapItem(inputItem); entity.ItemId = 0; _dbContext.Add(entity); }
public void AddOrder(Domain.Model.Order inputOrder) { if (inputOrder.Id != 0) { _logger.LogWarning($"Order to be added has an ID ({inputOrder.Id}) already: ignoring."); } _logger.LogInformation("Adding order"); Context.Order entity = new Context.Order { PersonId = inputOrder.UserId, OrderDate = inputOrder.Date, TotalOrderPrice = inputOrder.Price, }; entity.OrderId = 0; //_dbContext.Orders.Max(p => p.OrderId)+1; _dbContext.Add(entity); Save(); foreach (var val in inputOrder.Items) { val.OrderId = _dbContext.Orders.Max(p => p.OrderId); Repo.UpdateItem(val); } }