Ejemplo n.º 1
0
        public async Task DeleteAsync(BabyBook babyBook)
        {
            using (var uow = _uowFac.Create())
            {
                babyBook.Deleted = true;

                uow.BabyBookRepository.Update(babyBook);
                await uow.SaveChangesAsync();
            }
        }
Ejemplo n.º 2
0
        public async Task<BabyBook> UpdateAsync(BabyBook babyBook)
        {
            using (var uow = _uowFac.Create())
            {
                uow.BabyBookRepository.Update(babyBook);
                await uow.SaveChangesAsync();

                return babyBook;
            }
        }
Ejemplo n.º 3
0
        public async Task<BabyBook> InsertAsync(BabyBook babyBook)
        {
            using (var uow = _uowFac.Create())
            {
                babyBook.Id = Guid.NewGuid();

                uow.BabyBookRepository.Insert(babyBook);
                await uow.SaveChangesAsync();

                return babyBook;
            }
        }
Ejemplo n.º 4
0
        public async Task<IHttpActionResult> PostBabyBook(BabyBook babyBook)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

                var result = await _babyBookService.InsertAsync(babyBook);
                return Ok(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public async Task<IHttpActionResult> PutBabyBook(BabyBook babyBook)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

                if (babyBook.Id == Guid.Empty)
                    return BadRequest();

                var result = await _babyBookService.UpdateAsync(babyBook);
                return Ok(result);
            }
            catch (Exception)
            {
                throw;
            }
        }