示例#1
0
        public async Task PutLocationTypeAsync(LocationTypeV1DTO locationTypeDTO)
        {
            var locationType = await _context.LocationType
                               .Where(l => l.LocationTypeId == locationTypeDTO.LocationTypeId)
                               .SingleOrDefaultAsync();

            _context.Entry(locationType).CurrentValues.SetValues(locationTypeDTO);

            await _context.SaveChangesAsync();
        }
示例#2
0
        public void LocationType_should_not_have_errors()
        {
            var locationType = new LocationTypeV1DTO();

            locationType.LocationTypeName = "valid name";

            var Result = LocationTypeVal.TestValidate(locationType);

            Result.ShouldNotHaveValidationErrorFor(x => x.LocationTypeName);
        }
        public async Task <IActionResult> PutLocationType(int locationTypeId, [FromBody] LocationTypeV1DTO locationTypeDTO)
        {
            try
            {
                // Check to ensure service exists before calling contextmanager method.
                var locationType = await _contextManager.GetLocationTypeByIdAsync(locationTypeId);

                if (locationType == null)
                {
                    return(NotFound());
                }
                locationTypeDTO.LocationTypeId = locationTypeId;

                await _contextManager.PutLocationTypeAsync(locationTypeDTO);

                return(NoContent());
            }
            catch (Exception e)
            {
                throw e;
            }
        }