public messageModel save_draft(bookRoomDetailModel value) { messageModel result = new messageModel(); try { System.Data.Entity.Core.Objects.ObjectParameter myOutputParamInt = new System.Data.Entity.Core.Objects.ObjectParameter("r_id", typeof(Int32)); using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(value); context.interface_log.Add(new interface_log { ID = 1, data_log = json, module = "book_room_save_draft", update_date = DateTime.Now }); context.SaveChanges(); string save_type = "1"; // save_draft if (value.method.Equals("save_send")) { save_type = "2"; } //else if (value.method.Equals("save_revise")) //{ // save_type = "1"; //} int ret = context.sp_bookroom_save(value.id, value.topic, value.date, value.start_time, value.stop_time , value.room_id, value.person_total, value.remark, save_type, userId, myOutputParamInt, value.br_request); if (myOutputParamInt.Value != null) { int r_id = Convert.ToInt32(myOutputParamInt.Value); result.status = "S"; result.message = ""; result.value = r_id.ToString(); value.id = String.IsNullOrEmpty(value.id) ? r_id.ToString() : value.id; } else { result.status = "E"; result.message = ""; } context.sp_bookroom_delete_device(value.id); if (value.device_list != null) { foreach (var item in value.device_list) { if (item.opt) { context.sp_bookroom_insert_device(value.id, item.id); } } } context.sp_bookroom_delete_emp(value.id); if (value.emp_list != null) { foreach (var item in value.emp_list) { context.sp_bookroom_insert_emp(value.id, item.emp_code); } } } } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }