Exemplo n.º 1
0
        public async Task <IEnumerable <Visit> > Create(Visit visit)
        {
            Console.WriteLine($"Creating new visit");
            _dbContext.Visits.Add(visit);
            _dbContext.SaveChanges();

            return(await _dbContext.Visits.ToListAsync());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Save the cahnges made to the DB
 /// </summary>
 public void Save()
 {
     try
     {
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
        /// <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);
            }
        }
Exemplo n.º 5
0
 public int AddTEntity(TEntity tEntity)
 {
     _mariaDb.Set <TEntity>().Add(tEntity);
     return(_mariaDb.SaveChanges());
 }
Exemplo n.º 6
0
 public int AddProductInfo(ProductInfo productInfo)
 {
     _mariaDb.ProductInfos.Add(productInfo);
     return(_mariaDb.SaveChanges());
 }