public IActionResult Put(int id, [FromBody] SpecialtyVM model) { using (var context = new RypDbContext()) { var specialty = context.Specialties.FirstOrDefault(x => x.Id == id); specialty.Name = model.Name; specialty.Shifr = model.Shifr; specialty.UpdateDate = DateTime.Now.ToString(); context.SaveChanges(); } return(Ok()); }
public async Task <IActionResult> Post([FromBody] SpecialtyVM model) { var specialty = new Specialty(); using (var context = new RypDbContext()) { specialty.Name = model.Name; specialty.Shifr = model.Shifr; specialty.UserId = model.UserId; specialty.Date = DateTime.Now.ToString(); var result = await context.Specialties.AddAsync(specialty); context.SaveChanges(); } return(Ok()); }