public async Task <IEnumerable <Visit> > Create(Visit visit) { Console.WriteLine($"Creating new visit"); _dbContext.Visits.Add(visit); _dbContext.SaveChanges(); return(await _dbContext.Visits.ToListAsync()); }
public async Task <IEnumerable <Location> > Create(Location location) { Console.WriteLine($"Adding location {location.Name} to the database."); _dbContext.Locations.Add(location); _dbContext.SaveChanges(); // return success or failure (?) return(await _dbContext.Locations.ToListAsync()); }
/// <summary> /// Save the cahnges made to the DB /// </summary> public void Save() { try { context.SaveChanges(); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="userName"></param> /// <returns></returns> public virtual bool AddUser(string userName) { var userModel = new WUserInfoModel { Id = Guid.NewGuid().ToString(), UserName = userName, }; dbContext.UserInfoModels.Add(userModel); if (dbContext.SaveChanges() > 0) { return(true); } else { return(false); } }
public int AddTEntity(TEntity tEntity) { _mariaDb.Set <TEntity>().Add(tEntity); return(_mariaDb.SaveChanges()); }
public int AddProductInfo(ProductInfo productInfo) { _mariaDb.ProductInfos.Add(productInfo); return(_mariaDb.SaveChanges()); }