public IHttpActionResult GetConfigSetting(int id) { CarSalesConfigSetting carSalesConfigSetting = db.ConfigSettings.Where(e => e.ID == id).Select(e => new CarSalesConfigSetting() { ID = e.ID, VehicleAdvertisementNextRefNo = e.VehicleAdvertisementNextRefNo }).FirstOrDefault(); if (carSalesConfigSetting == null) { return(NotFound()); } return(Ok(carSalesConfigSetting)); }
public IHttpActionResult DeleteConfigSetting(int id) { ConfigSetting configSetting = db.ConfigSettings.Find(id); if (configSetting == null) { return(NotFound()); } db.ConfigSettings.Remove(configSetting); db.SaveChanges(); CarSalesConfigSetting carSalesConfigSetting = new CarSalesConfigSetting(); carSalesConfigSetting.ID = configSetting.ID; carSalesConfigSetting.VehicleAdvertisementNextRefNo = configSetting.VehicleAdvertisementNextRefNo; return(Ok(carSalesConfigSetting)); }
public IHttpActionResult PutConfigSetting(int id, CarSalesConfigSetting carSalesConfigSetting) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != carSalesConfigSetting.ID) { return(BadRequest()); } ConfigSetting configSetting = new ConfigSetting(); configSetting.ID = carSalesConfigSetting.ID; configSetting.VehicleAdvertisementNextRefNo = carSalesConfigSetting.VehicleAdvertisementNextRefNo; db.Entry(configSetting).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ConfigSettingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }