Example #1
0
 public async Task UpdateAsync([FromBody] InforMation employee)
 {
     try
     {
         var db = new DemoEntities();
         db.Entry(employee).State = EntityState.Modified;
         await db.SaveChangesAsync();
     }
     catch
     {
         throw;
     }
 }
Example #2
0
        public async Task DeleteAsync(string id)
        {
            try
            {
                var         db   = new DemoEntities();
                InforMation info = await db.InforMation.FindAsync(id);

                db.InforMation.Remove(info);
                await db.SaveChangesAsync();
            }
            catch
            {
                throw;
            }
            //await _iEmployeeRepository.Delete(id);
        }
Example #3
0
 public async Task CreateAsync([FromBody] InforMation employee)
 {
     if (ModelState.IsValid)
     {
         //await _iEmployeeRepository.Add(employee);
         using (var ctx = new DemoEntities())
         {
             ctx.InforMation.Add(new InforMation()
             {
                 Id      = employee.Id,
                 Name    = employee.Name,
                 Address = employee.Address,
                 Mobile  = employee.Mobile,
                 Email   = employee.Email
             });
             await ctx.SaveChangesAsync();
         }
     }
 }