public IActionResult Add([FromBody] dynamic cityData) { ValidateSession(); var result = ""; try { if (cityData != null) { App_CityPoco cityPoco = JsonConvert.DeserializeObject <App_CityPoco>(JsonConvert.SerializeObject(cityData[0])); using (var scope = new TransactionScope()) { cityPoco.IsActive = true; cityPoco.CreateDate = DateTime.Now; cityPoco.CreatedBy = sessionData.UserId; var cityId = _cityLogic.Add(cityPoco).Id; if (cityId > 0) { scope.Complete(); result = cityId.ToString(); } } } } catch (Exception ex) { } return(Json(result)); }
public IActionResult Update([FromBody] dynamic cityData) { ValidateSession(); var result = ""; try { if (cityData != null) { App_CityPoco cityPoco = JsonConvert.DeserializeObject <App_CityPoco>(JsonConvert.SerializeObject(cityData[0])); using (var scope = new TransactionScope()) { var existingCity = _cityLogic.GetSingleById(cityPoco.Id); existingCity.CityName = cityPoco.CityName; existingCity.ProvinceId = cityPoco.ProvinceId; existingCity.CountryId = cityPoco.CountryId; var cityId = _cityLogic.Update(existingCity).Id; if (cityId > 0) { scope.Complete(); result = cityId.ToString(); } } } } catch (Exception ex) { } return(Json(result)); }