Пример #1
0
 public ActionResult Edit(SettingValueViewModel item)
 {
     using (var context = new Uow(this.context))
     {
         var repos = new RepositorySettings(context);
         if (ModelState.IsValid)
         {
             repos.UpdateSetting(item);
             Success("Setting", "Save successful.");
             return(Json(new { success = true }));
         }
         return(PartialView(item));
     }
 }
Пример #2
0
        public HttpResponseMessage Post(SettingValueViewModel setting)
        {
            SettingValueViewModel settings = new SettingValueViewModel();

            _settings.UpdateSetting(setting);
            ResponseModel Response = new ResponseModel();

            Response.Success = true;
            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(JsonConvert.SerializeObject(Response), System.Text.Encoding.UTF8, "application/json");

            return(response);
        }
        public void RepositorySettingsTests_GivenAnUpdatedSetting_ShouldUpdateTheSetting()
        {
            //Arrange
            var expected = 1;

            //Act
            var setting = new SettingValueViewModel
            {
                SettingId    = 1,
                SettingName  = "LowVolume",
                SettingValue = 30,
                Active       = true
            };

            repos.UpdateSetting(setting);

            //Assert
            var actual = context.Object.SettingValues.Count(i => i.SettingName == "LowVolume" && i.SettingValue1 == 30);

            Assert.AreEqual(expected, actual);
        }