public CMSResult Delete(int boardId)
        {
            CMSResult result = new CMSResult();
            var       model  = _repository.Load <Board>(b => b.BoardId == boardId);

            if (model == null)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Board '{0}' already exists!", model.Name)
                });
            }
            else
            {
                var isExists = _repository.Project <Student, bool>(students => (
                                                                       from s in students
                                                                       where s.BoardId == boardId
                                                                       select s
                                                                       ).Any());

                if (isExists)
                {
                    result.Results.Add(new Result {
                        IsSuccessful = false, Message = string.Format("You can not delete Board '{0}'. Because it belongs to student!", model.Name)
                    });
                }
                else
                {
                    _repository.Delete(model);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Board '{0}' deleted successfully!", model.Name)
                    });
                }
            }
            return(result);
        }
        public CMSResult Update(Subject subject)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Subject, bool>(subjects =>
                                                                     (from subj in subjects
                                                                      where subj.SubjectId != subject.SubjectId &&
                                                                      subj.Name == subject.Name &&
                                                                      subj.ClassId == subject.ClassId
                                                                      select subj).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Subject '{0}' already exists!", subject.Name)
                });
            }
            else
            {
                var sub = _repository.Load <Subject>(x => x.SubjectId == subject.SubjectId);
                sub.ClassId = subject.ClassId;
                sub.Name    = subject.Name;
                _repository.Update(sub);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Subject '{0}' successfully updated!", subject.Name)
                });
            }
            return(result);
        }
        public CMSResult Update(UploadAssignments uploadNewAssignments)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <UploadAssignments, bool>(uploadAssignments => (
                                                                                   from p in uploadAssignments
                                                                                   where p.FileName == uploadNewAssignments.FileName && p.UploadAssignmentsId != uploadNewAssignments.UploadAssignmentsId
                                                                                   select p
                                                                                   ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Assignments file '{0}' already exists!", uploadNewAssignments.FileName)
                });
            }
            else
            {
                var Assignments = _repository.Load <UploadAssignments>(x => x.UploadAssignmentsId == uploadNewAssignments.UploadAssignmentsId);
                Assignments.ClassName   = uploadNewAssignments.ClassName;
                Assignments.Title       = uploadNewAssignments.Title;
                Assignments.FileName    = uploadNewAssignments.FileName;
                Assignments.LogoName    = uploadNewAssignments.LogoName;
                Assignments.BoardName   = uploadNewAssignments.BoardName;
                Assignments.SubjectName = uploadNewAssignments.SubjectName;
                Assignments.UploadDate  = uploadNewAssignments.UploadDate;
                Assignments.IsVisible   = uploadNewAssignments.IsVisible;
                _repository.Update(Assignments);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Assignments updated successfully!")
                });
            }
            return(result);
        }
        public CMSResult SendAppNotification(StudentTimetableViewModel viewModel, int studentClassTimetableId)
        {
            CMSResult cmsResult        = new CMSResult();
            var       notificationList = new List <SendNotificationByPlayerId>();

            try
            {
                var studentsList = _studentService.GetAllStudentParentList();
                if (viewModel.SelectedBranches != null)
                {
                    var branches = viewModel.SelectedBranches.Split(',').Select(x => int.Parse(x)).ToList();
                    studentsList = studentsList.Where(x => branches.Contains(x.BranchId));
                }
                if (viewModel.SelectedClasses != null)
                {
                    var classes = viewModel.SelectedClasses.Split(',').Select(x => int.Parse(x)).ToList();
                    studentsList = studentsList.Where(x => classes.Contains(x.ClassId));
                }
                if (viewModel.SelectedBatches != null)
                {
                    var batches = viewModel.SelectedBatches.Split(',').Select(x => int.Parse(x)).ToList();
                    studentsList = studentsList.Where(x => batches.Contains(x.BatchId));
                }

                var parentPlayerIds = studentsList.Where(x => !string.IsNullOrEmpty(x.parentAppPlayerId)).ToList();
                foreach (var playerId in parentPlayerIds)
                {
                    var studentSId          = playerId.SId;
                    var sendAppNotification = new SendNotificationByPlayerId
                    {
                        Message    = "CTT-" + viewModel.Description + "$^$" + playerId.SId + "@" + studentClassTimetableId,
                        PlayerIds  = playerId.parentAppPlayerId,
                        AppIds     = ConfigurationManager.AppSettings[Common.Constants.ParentAppId],
                        RestApiKey = ConfigurationManager.AppSettings[Common.Constants.ParentRestAppId]
                    };
                    notificationList.Add(sendAppNotification);
                }
                var notification = notificationList.ToArray();
                if (notificationList.Count > 0)
                {
                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => _sendNotificationService.StartProcessingByPlayerId(notification, cancellationToken));
                    cmsResult.Results.Add(new Result {
                        Message = "App Notification sent successfully.", IsSuccessful = true
                    });
                }
                else
                {
                    cmsResult.Results.Add(new Result {
                        Message = "No one is registered in parent app.", IsSuccessful = true
                    });
                }
            }
            catch (Exception ex)
            {
                cmsResult.Results.Add(new Result {
                    Message = ex.Message, IsSuccessful = true
                });
            }
            return(cmsResult);
        }
        public CMSResult Update(School oldSchool)
        {
            CMSResult result               = new CMSResult();
            var       isExists             = _repository.Project <School, bool>(schools => (from s in schools where s.SchoolId != oldSchool.SchoolId && s.Name == oldSchool.Name select s).Any());
            var       isExistsCenterNumber = _repository.Project <School, bool>(schools => (from s in schools where s.SchoolId != oldSchool.SchoolId && s.CenterNumber == oldSchool.CenterNumber select s).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("School '{0}' already exists!", oldSchool.Name)
                });
            }
            else if (isExistsCenterNumber)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("CenterNumber '{0}' already exists!", oldSchool.CenterNumber)
                });
            }
            else
            {
                var school = _repository.Load <School>(x => x.SchoolId == oldSchool.SchoolId);
                school.SchoolId     = oldSchool.SchoolId;
                school.Name         = oldSchool.Name;
                school.CenterNumber = oldSchool.CenterNumber;
                _repository.Update(school);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("School '{0}' successfully updated!", oldSchool.Name)
                });
            }
            return(result);
        }
        public CMSResult Save(StudentTimetable studentTimetable)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <StudentTimetable, bool>(studentTimetables => (
                                                                                  from p in studentTimetables
                                                                                  where p.Description == studentTimetable.Description && p.Category == studentTimetable.Category
                                                                                  select p
                                                                                  ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Time table '{0}' already exists !", studentTimetable.Description)
                });
            }
            else
            {
                _repository.Add(studentTimetable);
                _repository.CommitChanges();
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Time Table added successfully!")
                });
            }
            return(result);
        }
        public CMSResult Update(Branch branch)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Branch, bool>(branches => (from b in branches where b.BranchId != branch.BranchId && b.Name == branch.Name select b).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Branch '{0}' already exists!", branch.Name)
                });
            }
            else
            {
                var brch = _repository.Load <Branch>(x => x.BranchId == branch.BranchId);
                brch.Name    = branch.Name;
                brch.Address = branch.Address;

                if (brch.IsChangeDetected)
                {
                    _repository.Update(brch);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Branch '{0}' successfully updated!", branch.Name)
                    });
                }
                else
                {
                    _repository.Detach(brch);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = "No Change Detected!"
                    });
                }
            }
            return(result);
        }
        public CMSResult Save(OfflineTestPaper offlineTestPaper)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <OfflineTestPaper, bool>(OfflineTestPapers => (
                                                                                  from offlineTest in OfflineTestPapers
                                                                                  where offlineTest.Title == offlineTestPaper.Title
                                                                                  select offlineTest)
                                                                              .Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Exam schedule '{0}' already exists!", offlineTestPaper.Title)
                });
            }
            else
            {
                _repository.Add(offlineTestPaper);
                _repository.CommitChanges();
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Exam schedule Notification added successfully!")
                });
            }
            return(result);
        }
        public CMSResult Delete(int OfflineTestPaperId)
        {
            CMSResult result = new CMSResult();
            var       model  = _repository.Load <OfflineTestPaper>(m => m.OfflineTestPaperId == OfflineTestPaperId);

            if (model == null)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Offline Test Paper '{0}' already exists!", model.Title)
                });
            }
            else
            {
                var isExistsOfflineTestStudentMarks = _repository.Project <OfflineTestStudentMarks, bool>(offlineMarks => (
                                                                                                              from offlineMark in offlineMarks
                                                                                                              where offlineMark.OfflineTestPaperId == OfflineTestPaperId
                                                                                                              select offlineMark)
                                                                                                          .Any());
                if (isExistsOfflineTestStudentMarks)
                {
                    result.Results.Add(new Result {
                        IsSuccessful = false, Message = string.Format("You can not delete Exam Schedule '{0}'. Because it belongs to {1}!", model.Title, "UploadMarks")
                    });
                }
                else
                {
                    _repository.Delete(model);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Exam schedule '{0}' deleted successfully!", model.Title)
                    });
                }
            }
            return(result);
        }
Exemplo n.º 10
0
        public CMSResult DeleteImage(int questionId, int imageType)
        {
            CMSResult result = new CMSResult();
            var       model  = _repository.Load <Question>(x => x.QuestionId == questionId);

            if (model == null)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = "Question image not exists!"
                });
            }
            else
            {
                if (imageType == 1)
                {
                    model.QuestionImagePath = string.Empty;
                }
                if (imageType == 2)
                {
                    model.OptionImagePath = string.Empty;
                }
                if (imageType == 3)
                {
                    model.HintImagePath = string.Empty;
                }
                _repository.Update(model);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = "Question image deleted successfully!"
                });
            }
            return(result);
        }
Exemplo n.º 11
0
        public CMSResult Update(Question oldQuestion)
        {
            CMSResult cmsresult = new CMSResult();
            var       result    = new Result();
            var       ques      = _repository.Load <Question>(x => x.QuestionId == oldQuestion.QuestionId && x.ChapterId == oldQuestion.ChapterId);

            if (ques == null)
            {
                result.IsSuccessful = false;
                result.Message      = "Question not exist!";
            }
            else
            {
                ques.QuestionInfo     = oldQuestion.QuestionInfo;
                ques.OptionA          = oldQuestion.OptionA;
                ques.OptionB          = oldQuestion.OptionB;
                ques.OptionC          = oldQuestion.OptionC;
                ques.OptionD          = oldQuestion.OptionD;
                ques.Hint             = oldQuestion.Hint;
                ques.Numerical_Answer = oldQuestion.Numerical_Answer;
                ques.Unit             = oldQuestion.Unit;
                ques.QuestionLevel    = oldQuestion.QuestionLevel;
                ques.QuestionType     = oldQuestion.QuestionType;
                ques.QuestionYear     = oldQuestion.QuestionYear;
                ques.Answer           = oldQuestion.Answer;
                ques.ChapterId        = oldQuestion.ChapterId;

                _repository.Update(ques);

                result.IsSuccessful = true;
                result.Message      = string.Format("Question updated successfully!");
            }
            cmsresult.Results.Add(result);
            return(cmsresult);
        }
        public CMSResult UpdateMultipleFeedback(string selectedFeedback, string status)
        {
            var       commaseperatedList = selectedFeedback ?? string.Empty;
            var       FeedbackIds        = commaseperatedList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse);
            CMSResult cmsresult          = new CMSResult();
            var       result             = new Result();

            var feedback = _repository.LoadList <StudentFeedback>(x => FeedbackIds.Contains(x.StudentFeedbackId)).ToList();

            if (feedback == null)
            {
                result.IsSuccessful = false;
                result.Message      = "Feedback not exists!";
            }
            else
            {
                feedback.ForEach(x => x.Status = status);
                _repository.CommitChanges();
                result.IsSuccessful = true;
                result.Message      = string.Format("Student  Feedback updated successfully!");
            }

            cmsresult.Results.Add(result);
            return(cmsresult);
        }
Exemplo n.º 13
0
        public CMSResult Save(Attendance attendance)
        {
            var result   = new CMSResult();
            var isExists = _repository.Project <Attendance, bool>(attendances =>
                                                                  (from a in attendances
                                                                   where a.ClassId == attendance.ClassId &&
                                                                   a.BatchId == attendance.BatchId &&
                                                                   a.Date == attendance.Date &&
                                                                   a.BranchId == attendance.BranchId
                                                                   select a).Any());

            if (isExists)
            {
                result.Results.Add(new Result
                {
                    IsSuccessful = false,
                    Message      = string.Format("Attendance already exists!")
                });
            }
            else
            {
                _repository.Add(attendance);
                result.Results.Add(new Result
                {
                    IsSuccessful = true,
                    Message      = string.Format("Attendance successfully added!")
                });
            }
            return(result);
        }
 public HttpResponseMessage SubmitTest(TestResult testDetails)
 {
     try
     {
         CMSResult cmsResult = new CMSResult();
         var       questions = JsonConvert.SerializeObject(testDetails.Questions);
         var       result    = _arrangeTestService.Save(new ArrangeTestResult
         {
             UserId        = testDetails.UserId,
             TestPaperId   = testDetails.TestPaperId,
             TestDate      = testDetails.TestDate,
             TimeDuration  = testDetails.TimeDuration,
             StartTime     = testDetails.StartTime,
             Questions     = questions,
             ObtainedMarks = testDetails.ObtainedMarks,
             OutOfMarks    = testDetails.OutOfMarks
         });
         return(Request.CreateResponse(HttpStatusCode.OK, "OK"));
     }
     catch (Exception ex)
     {
         _logger.Warn(ex.Message);
         return(Request.CreateResponse(HttpStatusCode.OK, "Error"));
     }
 }
Exemplo n.º 15
0
        public CMSResult Update(Client client)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Client, bool>(clients => (from b in clients where b.ClientId != client.ClientId && b.Name == client.Name select b).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Client '{0}' already exists!", client.Name)
                });
            }
            else
            {
                var brch = _repository.Load <Client>(x => x.ClientId == client.ClientId);
                brch.Name    = client.Name;
                brch.Address = client.Address;

                if (brch.IsChangeDetected)
                {
                    _repository.Update(brch);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Client '{0}' successfully updated!", client.Name)
                    });
                }
                else
                {
                    _repository.Detach(brch);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = "No Change Detected!"
                    });
                }
            }
            return(result);
        }
        public CMSResult Update(OfflineTestPaper OfflineTestPaper)
        {
            CMSResult result = new CMSResult();

            var isExists = _repository.Project <OfflineTestPaper, bool>(ofline => (from b in ofline
                                                                                   where b.OfflineTestPaperId != OfflineTestPaper.OfflineTestPaperId && b.Title == OfflineTestPaper.Title
                                                                                   select b).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Offline Test '{0}' already exists!", OfflineTestPaper.Title)
                });
            }
            else
            {
                var offlineTests = _repository.Load <OfflineTestPaper>(x => x.OfflineTestPaperId == OfflineTestPaper.OfflineTestPaperId);

                offlineTests.Title       = OfflineTestPaper.Title;
                offlineTests.TestDate    = OfflineTestPaper.TestDate;
                offlineTests.TestInTime  = OfflineTestPaper.TestInTime;
                offlineTests.TestOutTime = OfflineTestPaper.TestOutTime;
                offlineTests.TotalMarks  = OfflineTestPaper.TotalMarks;
                _repository.Update(offlineTests);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Exam schedule '{0}' updated successfully!", offlineTests.Title)
                });
            }
            return(result);
        }
        public CMSResult Update(Chapter oldChapter)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Chapter, bool>(chapters =>
                                                                     (from chap in chapters
                                                                      where chap.ChapterId != oldChapter.ChapterId && chap.SubjectId == oldChapter.SubjectId && chap.Name == oldChapter.Name
                                                                      select chap).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Chapter '{0}' already exists!", oldChapter.Name)
                });
            }
            else
            {
                var chapt = _repository.Load <Chapter>(x => x.ChapterId == oldChapter.ChapterId);
                chapt.SubjectId = oldChapter.SubjectId;
                chapt.Name      = oldChapter.Name;
                chapt.Weightage = oldChapter.Weightage;
                _repository.Update(chapt);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Chapter '{0}' successfully updated!", oldChapter.Name)
                });
            }
            return(result);
        }
Exemplo n.º 18
0
        public CMSResult Delete(int pdfCategoryId)
        {
            CMSResult result = new CMSResult();
            var       model  = _repository.Load <PDFCategory>(p => p.PDFCategoryId == pdfCategoryId);

            if (model == null)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("PDF Category '{0}' already exists!", model.Name)
                });
            }
            else
            {
                var isExistsPDFUpload = _repository.Project <PDFUpload, bool>(pdfUploads => (
                                                                                  from s in pdfUploads
                                                                                  where s.PDFCategoryId == pdfCategoryId
                                                                                  select s)
                                                                              .Any());
                if (isExistsPDFUpload)
                {
                    result.Results.Add(new Result {
                        IsSuccessful = false, Message = string.Format("You can not delete PDF Category '{0}'. Because it belongs to PDF Upload!", model.Name)
                    });
                }
                else
                {
                    _repository.Delete(model);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("PDF Category '{0}' deleted successfully!", model.Name)
                    });
                }
            }
            return(result);
        }
        public CMSResult Update(StudentTimetable oldTimeTable)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <StudentTimetable, bool>(timetables =>
                                                                              (from timeTable in timetables
                                                                               where timeTable.StudentTimetableId != oldTimeTable.StudentTimetableId && timeTable.Description == oldTimeTable.Description && timeTable.Category == oldTimeTable.Category
                                                                               select timeTable).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Time table already exists!", "")
                });
            }
            else
            {
                var timetable = _repository.Load <StudentTimetable>(x => x.StudentTimetableId == oldTimeTable.StudentTimetableId);
                timetable.Description           = oldTimeTable.Description;
                timetable.AttachmentDescription = oldTimeTable.AttachmentDescription;
                timetable.StudentTimetableDate  = oldTimeTable.StudentTimetableDate;
                timetable.FileName = oldTimeTable.FileName;
                _repository.Update(timetable);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Time table successfully updated!", "")
                });
            }
            return(result);
        }
Exemplo n.º 20
0
        public CMSResult Save(PDFUpload newPdfUpload)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <PDFUpload, bool>(pdfs => (
                                                                           from p in pdfs
                                                                           where p.FileName == newPdfUpload.FileName
                                                                           select p
                                                                           ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("PDF file '{0}' already exists!", newPdfUpload.FileName)
                });
            }
            else
            {
                _repository.Add(newPdfUpload);
                _repository.CommitChanges();
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("PDF file '{0}' added successfully!", newPdfUpload.FileName)
                });
            }
            return(result);
        }
        public CMSResult Update(Batch oldBatch)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Batch, bool>(batches => (from batch in batches where batch.BatchId != oldBatch.BatchId && batch.ClassId == oldBatch.ClassId && batch.Name == oldBatch.Name select batch).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Batch '{0}' already exists!", oldBatch.Name)
                });
            }
            else
            {
                var btch = _repository.Load <Batch>(x => x.BatchId == oldBatch.BatchId);
                //  btch.ClassId = oldBatch.ClassId;
                btch.Name    = oldBatch.Name;
                btch.InTime  = oldBatch.InTime;
                btch.OutTime = oldBatch.OutTime;
                _repository.Update(btch);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Batch '{0}' successfully updated!", oldBatch.Name)
                });
            }
            return(result);
        }
Exemplo n.º 22
0
        public CMSResult Update(PDFUpload pdfUpload)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <PDFUpload, bool>(pdfs => (
                                                                           from p in pdfs
                                                                           where p.FileName == pdfUpload.FileName && p.PDFUploadId != pdfUpload.PDFUploadId
                                                                           select p
                                                                           ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("PDF file '{0}' already exists!", pdfUpload.FileName)
                });
            }
            else
            {
                var pdfs = _repository.Load <PDFUpload>(x => x.PDFUploadId == pdfUpload.PDFUploadId);
                pdfs.ClassId       = pdfUpload.ClassId;
                pdfs.Title         = pdfUpload.Title;
                pdfs.FileName      = pdfUpload.FileName;
                pdfs.IsVisible     = pdfUpload.IsVisible;
                pdfs.PDFCategoryId = pdfUpload.PDFCategoryId;
                if (!pdfs.IsSend)
                {
                    pdfs.IsSend = pdfUpload.IsSend;
                }
                _repository.Update(pdfs);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("PDF '{0}' updated successfully!", pdfUpload.FileName)
                });
            }
            return(result);
        }
        public CMSResult Update(UploadInbuiltquestionbank uploadNewInbuiltquestionbank)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <UploadInbuiltquestionbank, bool>(uploadInbuiltquestionbank => (
                                                                                           from p in uploadInbuiltquestionbank
                                                                                           where p.FileName == uploadNewInbuiltquestionbank.FileName && p.UploadInbuiltquestionbankId != uploadNewInbuiltquestionbank.UploadInbuiltquestionbankId
                                                                                           select p
                                                                                           ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Inbuiltquestionbank file '{0}' already exists!", uploadNewInbuiltquestionbank.FileName)
                });
            }
            else
            {
                var Inbuiltquestionbank = _repository.Load <UploadInbuiltquestionbank>(x => x.UploadInbuiltquestionbankId == uploadNewInbuiltquestionbank.UploadInbuiltquestionbankId);
                Inbuiltquestionbank.ClassName   = uploadNewInbuiltquestionbank.ClassName;
                Inbuiltquestionbank.Title       = uploadNewInbuiltquestionbank.Title;
                Inbuiltquestionbank.FileName    = uploadNewInbuiltquestionbank.FileName;
                Inbuiltquestionbank.LogoName    = uploadNewInbuiltquestionbank.LogoName;
                Inbuiltquestionbank.BoardName   = uploadNewInbuiltquestionbank.BoardName;
                Inbuiltquestionbank.SubjectName = uploadNewInbuiltquestionbank.SubjectName;
                Inbuiltquestionbank.UploadDate  = uploadNewInbuiltquestionbank.UploadDate;
                Inbuiltquestionbank.IsVisible   = uploadNewInbuiltquestionbank.IsVisible;
                _repository.Update(Inbuiltquestionbank);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Inbuiltquestionbank updated successfully!")
                });
            }
            return(result);
        }
        public CMSResult Update(DailyPracticePaper oldPaper)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <DailyPracticePaper, bool>(papers =>
                                                                                (from paper in papers
                                                                                 where paper.DailyPracticePaperId != oldPaper.DailyPracticePaperId && paper.Description == oldPaper.Description
                                                                                 select paper).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Practice paper already exists!", "")
                });
            }
            else
            {
                var paper = _repository.Load <DailyPracticePaper>(x => x.DailyPracticePaperId == oldPaper.DailyPracticePaperId);
                paper.Description            = oldPaper.Description;
                paper.AttachmentDescription  = oldPaper.AttachmentDescription;
                paper.DailyPracticePaperDate = oldPaper.DailyPracticePaperDate;
                paper.FileName = oldPaper.FileName;
                _repository.Update(paper);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Time table successfully updated!", "")
                });
            }
            return(result);
        }
        public CMSResult Save(School newSchool)
        {
            CMSResult result = new CMSResult();
            var       isExistsCenterNumber = false;
            var       isExistsName         = _repository.Project <School, bool>(schools => (from s in schools where s.Name == newSchool.Name select s).Any());

            if (newSchool.CenterNumber != null)
            {
                isExistsCenterNumber = _repository.Project <School, bool>(schools => (from s in schools where s.CenterNumber == newSchool.CenterNumber select s).Any());
            }
            if (isExistsName)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("School '{0}' already exists!", newSchool.Name)
                });
            }
            else if (isExistsCenterNumber)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("CenterNumber '{0}' already exists!", newSchool.CenterNumber)
                });
            }
            else
            {
                _repository.Add(newSchool);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("School '{0}' successfully added!", newSchool.Name)
                });
            }
            return(result);
        }
        public CMSResult Save(DailyPracticePaper dailyPracticePaper)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <DailyPracticePaper, bool>(dailyPracticePapers => (
                                                                                    from p in dailyPracticePapers
                                                                                    where p.Description == dailyPracticePaper.Description
                                                                                    select p
                                                                                    ).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("PDF file '{0}' already exists!", dailyPracticePaper.Description)
                });
            }
            else
            {
                _repository.Add(dailyPracticePaper);
                _repository.CommitChanges();
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Daily Practice Paper added successfully!")
                });
            }
            return(result);
        }
        public CMSResult Save(Subject subject, List <ClassProjection> classList)
        {
            CMSResult result = new CMSResult();

            foreach (var cls in classList)
            {
                var isExists = _repository.Project <Subject, bool>(subjects => (from subj in subjects where subj.Name == subject.Name && subj.ClassId == cls.ClassId select subj).Any());
                if (isExists)
                {
                    result.Results.Add(new Result {
                        IsSuccessful = false, Message = string.Format("Subject '{0}' already exists!", subject.Name + " - " + cls.Name)
                    });
                }
                else
                {
                    subject.ClassId = cls.ClassId;
                    _repository.Add(subject);
                    _repository.CommitChanges();
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Subject '{0}' successfully added!", subject.Name + " - " + cls.Name)
                    });
                }
            }
            return(result);
        }
        public CMSResult SendNotification(int classId, string title, string filename, string pdfCategory, int pdfuploadId)
        {
            var getStudentAppPlayerList = _studentService.GetStudentsAppPlayerIdByClass(classId);
            var sortlist = getStudentAppPlayerList.Where(x => !string.IsNullOrEmpty(x.studentAppPlayerId))
                           .Select(y => y.studentAppPlayerId).ToList();

            if (sortlist.Count > 0)
            {
                var result = _sendNotificationService.SendNotificationByPlayersId(new SendNotification
                {
                    Message    = "PDF-" + title + "$^$ File - " + filename + "$^$ Category - " + pdfCategory + "$^$" + pdfuploadId,
                    PlayerIds  = sortlist,
                    AppIds     = ConfigurationManager.AppSettings[Common.Constants.StudentAppId],
                    RestApiKey = ConfigurationManager.AppSettings[Common.Constants.StudentRestAppId]
                });

                return(result);
            }
            else
            {
                var result = new CMSResult();
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = "There is no student register."
                });
                return(result);
            }
        }
        public CMSResult Update(Installment oldInstallment)
        {
            CMSResult result = new CMSResult();

            var isExists = _repository.Project <Installment, bool>(
                installments => (from installment in installments
                                 where installment.InstallmentId != oldInstallment.InstallmentId &&
                                 installment.ReceiptBookNumber == oldInstallment.ReceiptBookNumber &&
                                 installment.ReceiptNumber == oldInstallment.ReceiptNumber
                                 select installment).Any());


            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Receipt Number already exists!")
                });
            }
            else
            {
                var installment = _repository.Load <Installment>(x => x.InstallmentId == oldInstallment.InstallmentId);
                installment.Payment           = oldInstallment.Payment;
                installment.ReceiptNumber     = oldInstallment.ReceiptNumber;
                installment.ReceiptBookNumber = oldInstallment.ReceiptBookNumber;
                installment.ReceivedFee       = oldInstallment.ReceivedFee;
                _repository.Update(installment);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Payment updated successfully!")
                });
            }
            return(result);
        }
        public CMSResult Save(MasterFee masterfee)
        {
            var result   = new CMSResult();
            var isExists = _repository.Project <MasterFee, bool>
                               (masterfees => (from mfee in masterfees
                                               where mfee.Year == masterfee.Year &&
                                               mfee.SubjectId == masterfee.SubjectId &&
                                               mfee.ClassId == masterfee.ClassId
                                               select mfee).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("MasterFee already exists!")
                });
            }
            else
            {
                _repository.Add(masterfee);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("MasterFee added successfully!")
                });
            }
            return(result);
        }