public void AddUser(Library.User user) { User u = Mapper.Map(user); u.DefaultLocation = db.Location.Find(user.DefaultLocation.LocationId); db.Add(u); db.SaveChanges(); user.UserId = u.UserId; }
//Add a location public void AddLocation(StoreLocation storeLocation) { if (storeLocation.Id != 0) { //Identity insert will not allow us to change the Id s_logger.Warn($"Location to be added has an ID ({storeLocation.Id}) already: ignoring."); } s_logger.Info($"Adding location"); StoreLocation entity = Mapper.MapStoreLocationWithOrdersAndProduct(storeLocation); entity.Id = 0; _dbContext.Add(entity); }