示例#1
0
        public async Task <bool> InsertOrUpdateAsync(SecondaryIdentity identity)
        {
            context.SecondaryIdentities.Update(identity);
            var updated = await context.SaveChangesAsync() == 1;

            return(updated);
        }
示例#2
0
        public async Task <IActionResult> InsertRangeAsync(Employee employee)
        {
            context.Add(employee);
            await context.SaveChangesAsync();

            return(Ok());
        }
示例#3
0
        public async Task <bool> CreateProductAsync(Product product)
        {
            if (product.Id != default(long))
            {
                return(false);
            }

            context.Products.Add(product);

            var affectedRows = await context.SaveChangesAsync();

            return(affectedRows > 0);
        }
示例#4
0
        public async Task <bool> UpdateCategoryAsync(Category category)
        {
            if (category.Id == default(long))
            {
                return(false);
            }

            context.Categories.Update(category);

            var affectedRows = await context.SaveChangesAsync();

            return(affectedRows > 0);
        }
示例#5
0
        public async Task InsertNewEmployeeAsync()
        {
            var employee = new Employee
            {
                SSN         = Guid.NewGuid().ToString(),
                FirstName   = "Vlad",
                FamilyName  = "Mis",
                Salary      = 500,
                LastUpdated = DateTime.Now
            };

            //context.Entry(employee).Property("LastUpdated").CurrentValue = DateTime.Now;

            context.Employees.Add(employee);
            await context.SaveChangesAsync();
        }