public IRestResponse MotCua_DM_ThuTuc_Save(DM_ThuTucSave model) { //var request = new RestRequest("MC/MotCua_DM_ThuTuc_Save", Method.POST) //{ // RequestFormat = DataFormat.Json, // JsonSerializer = new JsonSerializer(), //}; //request.AddBody(new //{ // model //}); //return Execute(request); var request = new RestRequest("MC/MotCua_DM_ThuTuc_Save", Method.POST) { RequestFormat = DataFormat.Json, JsonSerializer = new JsonSerializer() }; var settings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }; var json = JsonConvert.SerializeObject(model, settings); request.AddParameter("application/json", json, null, ParameterType.RequestBody); return(Execute(request)); }
public JsonResult SaveDMThuTuc() { try { using (MotCuaService = new MotCuaServiceClient()) { var modelDM_ThuTuc = Request.Form["model"]; var dm_ThuTuc = JsonConvert.DeserializeObject <DM_ThuTuc>(modelDM_ThuTuc); if (Session["DMThuTucID"] != null && Session["DMThuTucID"].ToString() != "0") { dm_ThuTuc.ThuTucID = Session["DMThuTucID"].ToString().ToInt(); } var modelDM_ChungTuKemTheo = Request.Form["chungtukemtheo"]; var lstdm_ChungTuKemTheo = JsonConvert.DeserializeObject <List <DM_ChungTuKemTheo> >(modelDM_ChungTuKemTheo ?? ""); if (dm_ThuTuc.ThuTucID != 0) { foreach (var item in lstdm_ChungTuKemTheo) { item.ThuTucID = dm_ThuTuc.ThuTucID; } } var dM_ThuTucSave = new DM_ThuTucSave(); dM_ThuTucSave.dm_ThuTuc = dm_ThuTuc; dM_ThuTucSave.lstDM_ChungTuKemTheo = lstdm_ChungTuKemTheo; var response = MotCuaService.MotCua_DM_ThuTuc_Save(dM_ThuTucSave); Session["DMThuTucID"] = null; return(Json(response.StatusCode != HttpStatusCode.OK ? null : new { response.Content }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Logger.Error(e.Message); Console.WriteLine(e); throw; } }