public async Task <IActionResult> PutContact(Guid id, Contact contact) { if (id != contact.Id) { return(BadRequest()); } _context.Entry(contact).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Teacher> Add(Teacher teacher) { _dbContext.Teachers.Add(teacher); await _dbContext.SaveChangesAsync(); return(teacher); }
public async Task <Core.Domain.Post> Add(Core.Domain.Post domain) { var post = new Enities.Post { Title = domain.Title, CreatedDate = domain.CreatedDate, ModifiedDate = domain.ModifiedDate, Content = domain.Content }; await _cmsDbContext.Posts.AddAsync(post); await _cmsDbContext.SaveChangesAsync(); return(new Core.Domain.Post { Content = post.Content, ModifiedDate = post.ModifiedDate, Title = post.Title, CreatedDate = post.CreatedDate, Id = post.Id }); }