public void Add_a_setting()
        {
            //Arrange
            //Arrange
            var origCount = _inMemRepo.GetListOf().Count;

            var newSetting = new SettingFromPost()
            {
                CustomerId    = Guid.NewGuid(),
                SettingTypeId = 1,
                SettingValue  = "Test Value"
            };

            //Act
            var response   = _controller.Post(newSetting);
            var viewResult = Assert.IsType <CreatedAtRouteResult>(response).Value;
            var setting    = (Setting)viewResult;

            // Assert
            var checkSetting = _inMemRepo.GetListOf(c => c.Id == setting.Id).SingleOrDefault();

            Assert.NotNull(checkSetting);
            Assert.Equal(checkSetting.Id, setting.Id);
            Assert.Equal(origCount + 1, _inMemRepo.GetListOf().Count);
        }
        public void Delete_a_setting()
        {
            //Arrange
            //Arrange

            var origCount = _inMemRepo.GetListOf().Count;

            var newSetting = new SettingFromPost()
            {
                CustomerId    = Guid.NewGuid(),
                SettingTypeId = 1,
                SettingValue  = "Test Value"
            };

            //Act
            // Add the record to delete
            var postAction    = _controller.Post(newSetting);
            var addViewResult = Assert.IsType <CreatedAtRouteResult>(postAction).Value;
            var setting       = (Setting)addViewResult;

            // Now delete the record
            var deleteAction = _controller.DeleteById(setting.Id);

            Assert.IsType <NoContentResult>(deleteAction);

            // Assert
            var checkSetting = _inMemRepo.GetListOf(c => c.Id == setting.Id).SingleOrDefault();

            Assert.Null(checkSetting);
            Assert.Equal(origCount, _inMemRepo.GetListOf().Count);
        }
        public IActionResult Post([FromBody] SettingFromPost settingFromPost)
        {
            if (settingFromPost == null)
            {
                return(BadRequest());
            }

            var maxSettinId = _repository.GetListOf().OrderByDescending(item => item.Id).First().Id;

            var setting = new Setting()
            {
                Id            = maxSettinId + 1,
                CustomerId    = settingFromPost.CustomerId,
                SettingTypeId = settingFromPost.SettingTypeId,
                SettingValue  = settingFromPost.SettingValue,
            };

            _repository.Add(setting);

            return(CreatedAtRoute("GetSetting", new { id = setting.Id }, setting));
        }