public Response SaveStudent([FromBody] StudentSaveObject _obj) { try { return(_manager.SaveStudent(_obj)); } catch (Exception ex) { return(new Response { status = -101, message = ex.Message }); } }
public Response SaveStudent(StudentSaveObject _obj, DataTable dt) { Response report = new Response(); try { var param = new { StudentID = _obj.studentID, FirstName = _obj.firstName, LastName = _obj.lastName, ClassName = _obj.className, datatable = dt }; using (IDbConnection db = new SqlConnection(connectionStr)) { var result = db.Query <int>("SaveStudent", param: param, commandType: CommandType.StoredProcedure); if (result != null) { report.status = result.FirstOrDefault(); report.message = "Student saved successfully."; } } } catch (SqlException ex) { report.status = -100; report.message = ex.Message; } catch (DataException ex) { report.status = -100; report.message = ex.Message; } catch (Exception ex) { report.status = -100; report.message = ex.Message.ToString(); } return(report); }
public Response SaveStudent(StudentSaveObject _obj) { try { DataTable dt = new DataTable(); dt.Columns.Add("SubjectID", typeof(int)); dt.Columns.Add("SubjectMarks", typeof(string)); DataRow dr = dt.NewRow(); foreach (SubjectObject item in _obj.subjectList) { dr["SubjectID"] = item.subjectID; dr["SubjectMarks"] = item.subjectMarks; dt.Rows.Add(dr); dr = dt.NewRow(); } return(_repo.SaveStudent(_obj, dt)); } catch (Exception ex) { return(new StudentObjectVM()); } }