Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        public async Task <Teacher> Add(Teacher teacher)
        {
            _dbContext.Teachers.Add(teacher);
            await _dbContext.SaveChangesAsync();

            return(teacher);
        }
Esempio n. 3
0
        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
            });
        }