Beispiel #1
0
        public async Task DeleteAsync(Child child)
        {
            using (var uow = _uowFac.Create())
            {
                child.Deleted = true;

                uow.ChildRepository.Update(child);
                await uow.SaveChangesAsync();
            }
        }
Beispiel #2
0
        public async Task<Child> UpdateAsync(Child child)
        {
            using (var uow = _uowFac.Create())
            {
                uow.ChildRepository.Update(child);
                await uow.SaveChangesAsync();

                return child;
            }
        }
Beispiel #3
0
        public async Task<Child> InsertAsync(Child child)
        {
            using (var uow = _uowFac.Create())
            {
                child.Id = new Guid();

                uow.ChildRepository.Insert(child);
                await uow.SaveChangesAsync();

                return child;
            }
        }
Beispiel #4
0
        public async Task<IHttpActionResult> PostChild(Child child)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

                var result = await _childService.InsertAsync(child);
                return Ok(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #5
0
        public async Task<IHttpActionResult> PutChild(Child child)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

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

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