コード例 #1
0
        public override async Task DeleteAStudent(StudentsLookupModel request, IServerStreamWriter <StudentsModel> responseStream, ServerCallContext context)
        {
            StudentsModel output = new StudentsModel();

            using (DbprofilDbcontext contxt = new DbprofilDbcontext())
            { var row          = contxt.profiles.FirstOrDefault(r => r.matricNo == request.MatricNo);
              var itemToRemove = contxt.profiles.SingleOrDefault(x => x.matricNo == request.MatricNo);

              if (itemToRemove != null)
              {
                  contxt.profiles.Remove(itemToRemove);
                  contxt.SaveChanges();
              }
              else
              {
              } }
            Dbrepository dbRptObj     = new Dbrepository();
            var          studentsList = dbRptObj.GetProfiles();

            foreach (var studentsData in studentsList)
            {
                output.MatricNo       = studentsData.matricNo;
                output.Name           = studentsData.name;
                output.ProfilePicture = Google.Protobuf.ByteString.FromBase64(Convert.ToBase64String(studentsData.profilePics));
                output.BloodGroup     = studentsData.bloodGroup;
                output.Programme      = studentsData.programme;
                output.School         = studentsData.school;
                await responseStream.WriteAsync(output);
            }
            // return base.DeleteAStudent(request, responseStream, context);
        }
コード例 #2
0
        public override async Task GetAllStudentsInfo(StudentLookup request, IServerStreamWriter <StudentsModel> responseStream, ServerCallContext context)
        {
            StudentsModel output       = new StudentsModel();
            Dbrepository  dbRptObj     = new Dbrepository();
            var           studentsList = dbRptObj.GetProfiles();

            foreach (var studentsData in studentsList)
            {
                output.MatricNo       = studentsData.matricNo;
                output.Name           = studentsData.name;
                output.ProfilePicture = Google.Protobuf.ByteString.FromBase64(Convert.ToBase64String(studentsData.profilePics));
                output.BloodGroup     = studentsData.bloodGroup;
                output.Programme      = studentsData.programme;
                output.School         = studentsData.school;
                await responseStream.WriteAsync(output);
            }
        }