Exemplo n.º 1
0
        public async Task DeleteAsync(Clinic clinic)
        {
            using (var uow = _uowFac.Create())
            {
                clinic.Deleted = true;

                uow.ClinicRepository.Update(clinic);
                await uow.SaveChangesAsync();
            }
        }
Exemplo n.º 2
0
        public async Task<Clinic> UpdateAsync(Clinic clinic)
        {
            using (var uow = _uowFac.Create())
            {
                uow.ClinicRepository.Update(clinic);
                await uow.SaveChangesAsync();

                return clinic;
            }
        }
Exemplo n.º 3
0
        public async Task<Clinic> InsertAsync(Clinic clinic)
        {
            using (var uow = _uowFac.Create())
            {
                clinic.Id = new Guid();

                uow.ClinicRepository.Insert(clinic);
                await uow.SaveChangesAsync();

                return clinic;
            }
        }
Exemplo n.º 4
0
        public async Task<IHttpActionResult> PostClinic(Clinic clinic)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

                var result = await _clinicService.InsertAsync(clinic);
                return Ok(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        public async Task<IHttpActionResult> PutClinic(Clinic clinic)
        {
            try
            {
                if (!ModelState.IsValid)
                    return BadRequest(ModelState);

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

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