public IActionResult Add([FromBody] dynamic provData) { ValidateSession(); var result = ""; try { if (provData != null) { App_ProvincePoco provPoco = JsonConvert.DeserializeObject <App_ProvincePoco>(JsonConvert.SerializeObject(provData[0])); using (var scope = new TransactionScope()) { provPoco.IsActive = true; provPoco.CreateDate = DateTime.Now; provPoco.CreatedBy = sessionData.UserId; var provId = _provinceLogic.Add(provPoco).Id; if (provId > 0) { scope.Complete(); result = provId.ToString(); } } } } catch (Exception ex) { } return(Json(result)); }
public IActionResult Update([FromBody] dynamic provData) { ValidateSession(); var result = ""; try { if (provData != null) { App_ProvincePoco provPoco = JsonConvert.DeserializeObject <App_ProvincePoco>(JsonConvert.SerializeObject(provData[0])); using (var scope = new TransactionScope()) { var existingProvince = _provinceLogic.GetSingleById(provPoco.Id); existingProvince.ProvinceName = provPoco.ProvinceName; existingProvince.ShortCode = provPoco.ShortCode; existingProvince.CountryId = provPoco.CountryId; //existingProvince.IsDefault = provPoco.IsDefault; var provId = _provinceLogic.Update(existingProvince).Id; if (provId > 0) { scope.Complete(); result = provId.ToString(); } } } } catch (Exception ex) { } return(Json(result)); }