Пример #1
0
        public bool CreateMentorReportCard([FromBody] MentorReportCard reportCardBody)
        {
            MentorReportCard requestBody = reportCardBody;

            Console.WriteLine("REPORT CARD BODY");
            Console.WriteLine(reportCardBody);
            Console.WriteLine("END REPORT CARD BODY");
            ReportCardService service = new ReportCardService();

            try
            {
                Console.WriteLine("Callling Service");
                service.createMentorReportCard(requestBody);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to save to db: {e}");
            }

            return(true);
        }
        public void createMentorReportCard(MentorReportCard requestBody)
        {
            MentorReportCard body = new MentorReportCard();

            body.mentorType         = (requestBody.mentorType == null) ? 8 : 0;
            body.mentorReportCardId = (requestBody.mentorReportCardId == null) ? 9 : 0;
            Console.WriteLine("In CreateMentoreReportCard");
            string sql = "INSERT INTO MentorReportCards (MentorReportCardID, MentorType) VALUES (@mentorReportCardID, @mentorType);";

            using (var dbConn = new MySqlConnection(conn_string.ToString()))
            {
                try
                {
                    Console.WriteLine("attempting sql execute");
                    dbConn.Execute(sql, new { mentorReportCardID = body.mentorReportCardId, mentorType = body.mentorType });
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to execute query: {e}");
                }
            }
        }