private List <string> ConvertToColumnValues(LecturerModel l)
        {
            List <string> colValues = new List <string>();

            try
            {
                colValues.Add(l.AccId.ToString());
                colValues.Add("'" + l.Name + "'");
                colValues.Add("'" + l.Surname + "'");
                colValues.Add("'" + l.Cell + "'");
                colValues.Add("'" + l.Email + "'");
                colValues.Add(l.Level.ToString());
            }
            catch (Exception)
            {
                throw;
            }

            return(colValues);
        }
Пример #2
0
        public List <DownloadFile> GetFiles()
        {
            List <DownloadFile> downloadFiles = new List <DownloadFile>();
            LecturerModel       lecturer      = HttpContext.Current.Session["USER"] as LecturerModel;
            DirectoryInfo       directoryInfo = new DirectoryInfo(HostingEnvironment.MapPath("~\\Exams\\" + lecturer.Username));

            int i = 0;

            foreach (FileInfo item in directoryInfo.GetFiles())
            {
                downloadFiles.Add(new DownloadFile()
                {
                    lecturerId = lecturer.LectID,
                    fileId     = i + 1,
                    fileName   = item.Name,
                    filePath   = directoryInfo.FullName + "\\" + item.Name
                });
                i++;
            }

            return(downloadFiles);
        }
        private static LecturerModel ConvertToLecturer(Dictionary <string, string> fieldValues)
        {
            LecturerModel l = new LecturerModel();

            foreach (KeyValuePair <string, string> row in fieldValues)
            {
                switch (row.Key)
                {
                case "id":
                    try
                    {
                        l.LectID = int.Parse(row.Value);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    break;

                case "AccountID":
                    try
                    {
                        l.AccId = int.Parse(row.Value);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    break;

                case "name":
                    l.Name = row.Value;
                    break;

                case "surname":
                    l.Surname = row.Value;
                    break;

                case "cell":
                    l.Cell = row.Value;
                    break;

                case "email":
                    l.Email = row.Value;
                    break;

                case "LecturerLevel":
                    try
                    {
                        l.Level = int.Parse(row.Value);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    break;

                default:
                    break;
                }
            }
            return(l);
        }