public static async Task <string> GetAllSubjects(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage request, ILogger log)
        {
            {
                OperationResult operationResult = new OperationResult();
                SubjectRequest  subjectsRequest = await Utilities.ExtractContent <SubjectRequest>(request);

                var allSubjects = SubjectsTableUtilities.GetAllSubjects(subjectsRequest.tableName);
                operationResult.UpdateData(allSubjects);
                return(JsonConvert.SerializeObject(operationResult));
            }
        }
        public static async Task <string> EditSubject(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage request, [SignalR(HubName = "Pack2SchoolSignalR1")] IAsyncCollector <SignalRMessage> signalRMessages, ILogger log)
        {
            OperationResult operationResult    = new OperationResult();
            SubjectRequest  editSubjectRequest = await Utilities.ExtractContent <SubjectRequest>(request);

            var    subjectsTable          = CloudTableUtilities.OpenTable(editSubjectRequest.tableName);
            var    classSubjectsNames     = CloudTableUtilities.getTableEntityAsync <SubjectsTable>(subjectsTable, SubjectsTableUtilities.ClassSubjects).Result.First();
            var    classSubjectsNecessity = CloudTableUtilities.getTableEntityAsync <SubjectsTable>(subjectsTable, SubjectsTableUtilities.Necessity).Result.First();
            var    classesTable           = CloudTableUtilities.OpenTable(ProjectConsts.classesTableName);
            var    classesEntities        = CloudTableUtilities.getTableEntityAsync <ClassesTable>(classesTable).Result;
            string scheduleTableName      = null;

            foreach (var classEntity in classesEntities)
            {
                if (classEntity.subjectsTableName == editSubjectRequest.tableName)
                {
                    scheduleTableName = classEntity.ScheduleTableName;
                    break;
                }
            }

            if (editSubjectRequest.requestType == ProjectConsts.AddSubjectOperation)
            {
                SubjectsTableUtilities.AddNewSubject(editSubjectRequest, classSubjectsNames, classSubjectsNecessity, operationResult);
            }

            if (editSubjectRequest.requestType == ProjectConsts.RenameSubjectOperation)
            {
                await SubjectsTableUtilities.RenameSubjectAsync(editSubjectRequest, classSubjectsNames, scheduleTableName, classSubjectsNecessity, operationResult);
            }

            if (editSubjectRequest.requestType == ProjectConsts.DeleteSubjectOperation)
            {
                await SubjectsTableUtilities.DeleteSubjectAsync(editSubjectRequest, classSubjectsNames, scheduleTableName, classSubjectsNecessity, operationResult);
            }

            await CloudTableUtilities.AddTableEntity(subjectsTable, classSubjectsNames);

            await CloudTableUtilities.AddTableEntity(subjectsTable, classSubjectsNecessity);

            var neededSubjects = SubjectsTableUtilities.GetNeededSubject(editSubjectRequest.tableName);
            var allSubjects    = SubjectsTableUtilities.GetAllSubjects(editSubjectRequest.tableName);
            var studentsIds    = SubjectsTableUtilities.GetAllStudentsIds(editSubjectRequest.tableName);

            foreach (var studentId in studentsIds)
            {
                var missingSubjects = SubjectsTableUtilities.GetMissingSubejcts(editSubjectRequest.tableName, studentId);

                var dataBaseAndScanUpdates = new DataBaseAndScanUpdates(studentId, neededSubjects, missingSubjects, allSubjects);

                await signalRMessages.AddAsync(
                    new SignalRMessage
                {
                    UserId    = studentId,
                    Target    = ProjectConsts.SignalRTarget,
                    Arguments = new object[] { dataBaseAndScanUpdates }
                });
            }

            return(JsonConvert.SerializeObject(operationResult));
        }