public bool SaveInfoHandover(string code, string note, int status) { try { LogHandoverAdvisorRepository.Insert_LogHandoverAdvisor(code, note, status); ContactLevelInfoRepository.UpdateHandoverAdvisorStatus(code, status); return(true); } catch (Exception ex) { return(false); } }
public ActionResult HandoverContact(ContactLevelInfoModel model) { string linkApiHandoverAdvisor = ConfigurationManager.AppSettings["LinkAPIHandoverAdvisor"].ToString(); //if (model.ContactLevelInfo.HandoverAdvisor == 1) //{ string username = "******"; string password = "******"; var contactid = model.ContactInfo.Id; var code = model.ContactInfo.Code; var phone = model.ContactInfo.Mobile1; var email = model.ContactInfo.Email; var fullname = model.ContactInfo.Fullname; var gender_id = model.ContactInfo.Gender; var note = model.ContactLevelInfo.DacDiemHocVien; int iFeeMoneyType = model.ContactLevelInfo.FeeMoneyType; var package_want_to_learn = model.ContactLevelInfo.PackageWantToLearn; var level_crm = model.ContactInfo.LevelId.ToString(); var deposit_need = model.ContactLevelInfo.PackagePriceSale; var actually_paid = model.ContactLevelInfo.FeeEdu; //var technical_test = model.ContactLevelInfo.HasTestTechnical; //da kiem tra ky thuat chua var technical_test = 1; var tvts_id = model.ContactInfo.Consultant; var tvts_name = model.ContactInfo.UserName; var transaction_reason = model.ContactLevelInfo.TransactionReason; var sb100 = model.TestResultLinkSb100Info.LinkSb100 != null? model.TestResultLinkSb100Info.LinkSb100: ""; var casec_total = model.TestResultCasecInfo.TotalCasec; var toiec_total = model.TestResultTopicaInfo.TotalTopica; var interview_total = model.TestResultInterviewInfo.TotalInterview; var tvts_phone = Request["PhoneTVTS"].ToString(); var time_want_to_learn = (Request["time_want_to_learn"]); if (!time_want_to_learn.IsStringNullOrEmpty()) { time_want_to_learn += string.IsNullOrEmpty(model.Time24hWantToLearn) ? " 00:00:00" : " " + model.Time24hWantToLearn; } var tvts_email = Request["EmailTVTS"].ToString(); int level_study_id = Int32.Parse(Request["LevelStudyAdvisor"]); string level_study; string gender; if (gender_id == 1) { gender = "Nam"; } else { gender = "Nữ"; } if (level_study_id == 1) { level_study = "basic100"; } else if (level_study_id == 2) { level_study = "basic200"; } else if (level_study_id == 3) { level_study = "basic300"; } else if (level_study_id == 4) { level_study = "inter100"; } else if (level_study_id == 5) { level_study = "inter200"; } else if (level_study_id == 6) { level_study = "inter300"; } else if (level_study_id == 7) { level_study = "advan100"; } else if (level_study_id == 8) { level_study = "advan200"; } else if (level_study_id == 9) { level_study = "advan300"; } else { level_study = "sbasic"; } var client = new RestClient(linkApiHandoverAdvisor); client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest(); if (model.ContactLevelInfo.HandoverAdvisor == 1) { request = new RestRequest("advisor_api/create_new_student_info", Method.POST); } else if (model.ContactLevelInfo.HandoverAdvisor == 3) { request = new RestRequest("advisor_api/update_new_student_info", Method.POST); } request.AddHeader("Accept", "application/json"); request.AddParameter("key", "SSeKfm7RXCJZxnFUleFsPf63o2ymZ93fWuCmvC34"); request.AddParameter("contact_id", code); request.AddParameter("phone", phone); request.AddParameter("email", email); request.AddParameter("full_name", fullname); request.AddParameter("gender", gender); request.AddParameter("package_want_to_learn", package_want_to_learn); request.AddParameter("lang", "vi"); request.AddParameter("note", note); request.AddParameter("level_crm", "L" + level_crm); request.AddParameter("deposit_need", deposit_need); request.AddParameter("actually_paid", actually_paid); request.AddParameter("technical_test", technical_test); request.AddParameter("tvts_id", tvts_id); request.AddParameter("tvts_name", tvts_name); request.AddParameter("actually_paid", actually_paid); request.AddParameter("transaction_reason", transaction_reason); request.AddParameter("sb100", sb100); request.AddParameter("casec_total", casec_total); request.AddParameter("toiec_total", toiec_total); request.AddParameter("interview_total", interview_total); request.AddParameter("tvts_phone", tvts_phone); request.AddParameter("time_want_to_learn", time_want_to_learn); request.AddParameter("tvts_email", tvts_email); request.AddParameter("level_study", level_study); try { request.JsonSerializer.ContentType = "application/json; charset=utf-8"; IRestResponse response = client.Execute(request); var content = response.Content; var input = JsonConvert.DeserializeObject <LogTaoHocVien>(content); if (input.state == 1) { ViewBag.Close = 1; ViewBag.Message = "Bàn giao thành công"; int value = (int)StatusHandoverAdvisor.Handover; ContactLevelInfoRepository.UpdateHandoverAdvisorStatusWithContactId(contactid, value); ContactLevelInfoRepository.UpdateLevelStudyAdvisor(contactid, level_study_id); DateTime dt_timewanttolearn = DateTime.ParseExact(time_want_to_learn, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); ContactLevelInfoRepository.Update_DateWantToLearn(contactid, dt_timewanttolearn); //Viet them ham cap nhat da kiem tra test ky thuat LogHandoverAdvisorRepository.Insert_LogHandoverAdvisor(code, "", value); return(HandoverContact(model.ContactInfo.Id, model)); } else { ViewBag.Message = "Bàn giao không thành công: " + input.msg; return(HandoverContact(model.ContactInfo.Id, model)); } } catch (Exception ex) { ViewBag.Message = "Đã có lỗi xảy ra, vui lòng thực hiện lại!"; return(HandoverContact(model.ContactInfo.Id, model)); } return(HandoverContact(model.ContactInfo.Id, model)); }