public async Task <IActionResult> PutUnitOfMeasurement([FromRoute] int id, [FromBody] UnitOfMeasurement unitOfMeasurement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != unitOfMeasurement.Id)
            {
                return(BadRequest());
            }

            _context.Entry(unitOfMeasurement).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UnitOfMeasurementExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutMessage([FromRoute] int id, [FromBody] Message message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != message.Id)
            {
                return(BadRequest());
            }

            _context.Entry(message).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MessageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(message));
        }
Esempio n. 3
0
        public async Task <IActionResult> PutRefRange([FromRoute] int id, [FromBody] RefRange refRange)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != refRange.Id)
            {
                return(BadRequest());
            }

            refRange.DateModified = DateTime.Now;
            refRange.ModifiedBy   = HttpContext.User.Identity.Name;

            _context.Entry(refRange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RefRangeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(refRange));
        }
Esempio n. 4
0
        public async Task <IActionResult> PutTest([FromRoute] int id, [FromBody] Test test)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != test.Id)
            {
                return(BadRequest());
            }

            test.DateModified = DateTime.Now;
            test.ModifiedBy   = HttpContext.User.Identity.Name;

            _context.Entry(test).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            UpdateTestTags(test);

            test = await _context.Tests
                   .Include(t => t.Department)
                   .ThenInclude(d => d.Contacts)
                   .ThenInclude(c => c.ContactDetails)
                   .ThenInclude(cd => cd.ContactType)
                   .Include(t => t.Containers)
                   .ThenInclude(c => c.SpecimenType)
                   .Include(t => t.Containers)
                   .ThenInclude(c => c.CollectionContainerType)
                   .Include(t => t.Tags)
                   .ThenInclude(tt => tt.TagType)
                   .Include(t => t.RefRanges)
                   .SingleOrDefaultAsync(m => m.Id == id);

            if (test == null)
            {
                return(NotFound());
            }

            return(Ok(test));
        }
        public async Task <IActionResult> PutContainerDetails([FromRoute] int id, [FromBody] ContainerDetails containerDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != containerDetails.Id)
            {
                return(BadRequest());
            }

            containerDetails.DateModified   = DateTime.Now;
            containerDetails.ModifiedBy     = HttpContext.User.Identity.Name;
            containerDetails.GeneralDetails = UpdateGeneralDetails(containerDetails);

            _context.Entry(containerDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContainerDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            var updatedContainerDetails = await _context.ContainerDetails
                                          .Include(cd => cd.CollectionContainerType)
                                          .Include(cd => cd.SpecimenType)
                                          .SingleOrDefaultAsync(cd => cd.Id == id);

            if (updatedContainerDetails == null)
            {
                return(NotFound());
            }

            return(Ok(updatedContainerDetails));
        }
        public async Task <IActionResult> PutDepartment([FromRoute] int id, [FromBody] Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != department.Id)
            {
                return(BadRequest());
            }

            if (DuplicateValues(department))
            {
                return(BadRequest(department));
            }

            department.DateModified = DateTime.Now;
            department.ModifiedBy   = HttpContext.User.Identity.Name;

            _context.Entry(department).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutTagType([FromRoute] int id, [FromBody] TagType tagType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tagType.Id)
            {
                return(BadRequest());
            }

            if (DuplcateValues(tagType))
            {
                return(BadRequest(tagType));
            }

            tagType.ModifiedBy   = HttpContext.User.Identity.Name;
            tagType.DateModified = DateTime.Now;

            _context.Entry(tagType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TagTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutContactDetail([FromRoute] int id, [FromBody] ContactDetail contactDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != contactDetail.Id)
            {
                return(BadRequest());
            }

            if (DuplicateValues(contactDetail))
            {
                return(BadRequest(contactDetail));
            }

            contactDetail.DateModified = DateTime.Now;
            contactDetail.ModifiedBy   = HttpContext.User.Identity.Name;

            _context.Entry(contactDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutTag([FromRoute] int id, [FromBody] Tag tag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tag.Id)
            {
                return(BadRequest());
            }

            tag.DateModified = DateTime.Now;
            tag.ModifiedBy   = HttpContext.User.Identity.Name;

            _context.Entry(tag).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                tag.TagType =
                    _context.TagTypes.SingleOrDefault(tt => tt.Code == Enum.GetName(typeof(TagTypeEnums), TagTypeEnums.Synonym));

                return(Ok(tag));
            }
            catch (Exception e)
            {
                if (!TagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }