예제 #1
0
        public StatusDTO <FacultyCourseMapDTO> InsertFacultyCourse(FacultyCourseMapDTO data)
        {
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "Teacher_Course_Map";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Connection  = dbSvc.GetConnection() as MySqlConnection;

                    command.Parameters.Add("@EmployeeId", MySqlDbType.String).Value = data.Employee.EmployeeId;
                    command.Parameters.Add("@SubjectId", MySqlDbType.String).Value  = data.Subject.SubjectId;
                    //if(Convert.ToInt32(data.CreatedBy.UserMasterId) > 0)
                    //{
                    //    command.Parameters.Add("@CreatedBy", MySqlDbType.String).Value = data.CreatedBy.UserMasterId;
                    //}
                    //else
                    //{
                    command.Parameters.Add("@CreatedBy", MySqlDbType.String).Value = DBNull.Value;
                    //}

                    MySqlDataReader rdr = command.ExecuteReader(CommandBehavior.CloseConnection);
                    _dtData = new DataTable();
                    _dtData.Load(rdr);
                    StatusDTO <FacultyCourseMapDTO> status = new StatusDTO <FacultyCourseMapDTO>();
                    return(status);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
        }
예제 #2
0
        public StatusDTO <FacultyCourseMapDTO> UpdateFacultyCourseMap(FacultyCourseMapDTO data)
        {
            StatusDTO <FacultyCourseMapDTO> status = new StatusDTO <FacultyCourseMapDTO>();

            status.IsSuccess = false;
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "UPDATE facultycoursemap set SubjectId=@SubjectId WHERE FacultyCourseMapId=@FacultyCourseMapId";
                    command.Parameters.Add("@FacultyCourseMapId", MySqlDbType.Int32).Value = data.FacultyCourseMapId;
                    command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value          = data.Subject.SubjectId;

                    command.Connection = dbSvc.GetConnection() as MySqlConnection;

                    if (command.ExecuteNonQuery() > 0)
                    {
                        status.IsSuccess = true;
                    }
                    return(status);
                }
                catch (Exception exp)
                {
                    _logger.Log(exp);
                    throw exp;
                }
            }
        }
예제 #3
0
 public JsonResult DeleteFacultyCourseMap(FacultyCourseMapDTO facultyCourseMap)
 {
     if (_userSvc.DeleteFacultyCourseMap(facultyCourseMap).IsSuccess)
     {
         return(Json(new { status = true, message = "Deleted successfully." }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { status = false, message = "Delete failed." }, JsonRequestBehavior.AllowGet));
 }
예제 #4
0
        //to get Faculty Course map
        public List <FacultyCourseMapDTO> GetFacultyCourseMap(int employeeId)
        {
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "SELECT FacultyCourseMapId, EmployeeId, SubjectId FROM facultycoursemap WHERE EmployeeId=@employeeId";
                    command.Parameters.Add("@employeeId", MySqlDbType.Int32).Value = employeeId;
                    command.Connection = dbSvc.GetConnection() as MySqlConnection;

                    MySqlDataAdapter mDa = new MySqlDataAdapter(command);
                    _dtData = new DataTable();
                    mDa.Fill(_dtData);
                    List <FacultyCourseMapDTO> lstFCMap = null;
                    if (_dtData != null && _dtData.Rows.Count > 0)
                    {
                        lstFCMap = new List <FacultyCourseMapDTO>();
                        FacultyCourseMapDTO fcmpDTO = null;
                        foreach (DataRow dr in _dtData.Rows)
                        {
                            fcmpDTO          = new FacultyCourseMapDTO();
                            fcmpDTO.Employee = new EmployeeDetailsDTO();
                            fcmpDTO.Subject  = new SubjectDTO();

                            fcmpDTO.FacultyCourseMapId  = (int)dr["FacultyCourseMapId"];
                            fcmpDTO.Employee.EmployeeId = (int)dr["EmployeeId"];
                            fcmpDTO.Subject.SubjectId   = (int)dr["SubjectId"];

                            lstFCMap.Add(fcmpDTO);
                        }
                    }
                    return(lstFCMap);
                }
                catch (Exception exp)
                {
                    _logger.Log(exp);
                    throw exp;
                }
            }
        }