Пример #1
0
 public IEnumerable <object> Get()
 {
     using (var AppContext = new TestEmployeeContext())
     {
         return(AppContext.Employee.ToList());
     }
 }
Пример #2
0
 public bool Save([FromBody] Employee value)
 {
     using (var AppContext = new TestEmployeeContext())
     {
         AppContext.Employee.Add(value);
         AppContext.SaveChanges();
         return(true);
     }
 }
Пример #3
0
 //[HttpPost("{id}")]
 public bool Delete([FromBody] Employee data)
 {
     using (var AppContext = new TestEmployeeContext())
     {
         Employee save = AppContext.Employee.FirstOrDefault(obj => obj.Id == data.Id);
         AppContext.Employee.Remove(save);
         AppContext.SaveChanges();
         return(true);
     }
 }
Пример #4
0
 public bool Put([FromBody] Employee value)
 {
     using (var AppContext = new TestEmployeeContext())
     {
         Employee save = AppContext.Employee.FirstOrDefault(obj => obj.Id == value.Id);
         save.FirstName = value.FirstName;
         save.LastName  = value.LastName;
         save.Email     = value.Email;
         AppContext.Employee.Update(save);
         AppContext.SaveChanges();
         return(true);
     }
 }