public bool AddReport(MBTIReport report) { report.TypeCode = report.E > report.I ? "E" : "I"; report.TypeCode += report.S > report.N ? "S" : "N"; report.TypeCode += report.T > report.F ? "T" : "F"; report.TypeCode += report.J > report.P ? "J" : "P"; report.CreateDate = DateTime.Now; return(_data.InsertReport(report)); }
public bool InsertReport(MBTIReport report) { using (_connection = DBHelper.GetOpenConnection()) { int?id = _connection.Insert(report); if (id.HasValue && id.Value > 0) { return(true); } return(false); } }
public ActionResult Testing(string answers) { var report = new MBTIReport(); report.OpenId = this.OpenId; report.E = answers.Length - answers.Replace("E", "").Length; report.I = answers.Length - answers.Replace("I", "").Length; report.F = answers.Length - answers.Replace("F", "").Length; report.J = answers.Length - answers.Replace("J", "").Length; report.N = answers.Length - answers.Replace("N", "").Length; report.P = answers.Length - answers.Replace("P", "").Length; report.S = answers.Length - answers.Replace("S", "").Length; report.T = answers.Length - answers.Replace("T", "").Length; bool result = _service.AddReport(report); return(Content("ok")); }