示例#1
0
        public async Task AddStudent(HttpPostedFileBase uploadFile, Student student)
        {
            BlobBussines BlobObj         = new BlobBussines("picture");
            string       FileAbsoluteUri = BlobObj.UploadFile(uploadFile);
            FeedOptions  queryOptions    = new FeedOptions {
                MaxItemCount = -1
            };

            IQueryable <Student> studentQuery = this.client.CreateDocumentQuery <Student>(
                UriFactory.CreateDocumentCollectionUri("ToDoList", "Items"), queryOptions)
                                                .Where(f => f.studentName != "");

            Student Studentz = new Student();

            student.imageUri      = FileAbsoluteUri;
            student.studentNumber = 1;
            if (studentQuery != null)
            {
                foreach (var item in studentQuery.ToList())
                {
                    Studentz.studentNumber = item.studentNumber;
                }
                student.studentNumber = Studentz.studentNumber + 1;
            }
            await this.client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("ToDoList", "Items"), student);
        }
示例#2
0
        public async Task <List <Student> > StudentsList(string stName)
        {
            await client.CreateDatabaseIfNotExistsAsync(new Database { Id = "ToDoList" });

            await client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri("ToDoList"),
                                                                  new DocumentCollection { Id = "Items" });


            FeedOptions queryOptions = new FeedOptions {
                MaxItemCount = -1
            };


            IQueryable <Student> studentQuery = this.client.CreateDocumentQuery <Student>(
                UriFactory.CreateDocumentCollectionUri("ToDoList", "Items"), queryOptions)
                                                .Where(f => f.studentName != "");

            if (!String.IsNullOrEmpty(stName))
            {
                studentQuery = studentQuery.Where(m => m.studentName.Contains(stName) && m.IsActive == false);
            }
            string[]     kl   = new string[25];
            BlobBussines blob = new BlobBussines("picture");
            int          i    = 0;

            foreach (var item in blob.BlobList())
            {
                kl[i] = item;
                i     = i + 1;
            }
            i = 0;
            List <Student> students = new List <Student>();

            foreach (var item in studentQuery)
            {
                Student studente = new Student();
                studente.imageUri      = item.imageUri;
                studente.IsActive      = item.IsActive;
                studente.mobile        = item.mobile;
                studente.IsDeleted     = item.IsDeleted;
                studente.studentName   = item.studentName;
                studente.studentNumber = item.studentNumber;
                studente.surname       = item.surname;
                studente.telphone_No   = item.telphone_No;
                studente.email         = item.email;
                studente.Id            = item.Id;
                students.Add(studente);
                i = i + 1;
            }

            students = students.Where(m => m.IsDeleted == false).ToList();
            return(students);
        }