本文整理汇总了C#中LmPlatformRepositoriesContainer.RepositoryFor方法的典型用法代码示例。如果您正苦于以下问题:C# LmPlatformRepositoriesContainer.RepositoryFor方法的具体用法?C# LmPlatformRepositoriesContainer.RepositoryFor怎么用?C# LmPlatformRepositoriesContainer.RepositoryFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LmPlatformRepositoriesContainer
的用法示例。
在下文中一共展示了LmPlatformRepositoriesContainer.RepositoryFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteLabs
public void DeleteLabs(int id)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
var labs =
repositoriesContainer.LabsRepository.GetBy(
new Query<Labs>(e => e.Id == id).Include(e => e.StudentLabMarks));
var deleteFiles =
repositoriesContainer.AttachmentRepository.GetAll(
new Query<Attachment>(e => e.PathName == labs.Attachments)).ToList();
var studentLabMarks =
repositoriesContainer.RepositoryFor<StudentLabMark>()
.GetAll(new Query<StudentLabMark>(e => e.LabId == id))
.ToList();
foreach (var attachment in deleteFiles)
{
FilesManagementService.DeleteFileAttachment(attachment);
}
foreach (var mark in studentLabMarks)
{
repositoriesContainer.RepositoryFor<StudentLabMark>().Delete(mark);
}
repositoriesContainer.ApplyChanges();
repositoriesContainer.LabsRepository.Delete(labs);
repositoriesContainer.ApplyChanges();
}
}
示例2: SaveQuestion
public Question SaveQuestion(Question question)
{
CheckForTestIsNotLocked(question.TestId);
ValidateQuestion(question);
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.QuestionsRepository.Save(question);
Question existingQuestion = GetQuestion(question.Id);
var answersToDelete = existingQuestion.Answers.Where(a => question.Answers.All(answer => answer.Id != a.Id));
// TODO: Resolve problem (items are saved only first time)
foreach (Answer answer in question.Answers)
{
answer.QuestionId = question.Id;
}
repositoriesContainer.RepositoryFor<Answer>().Save(question.Answers);
repositoriesContainer.RepositoryFor<Answer>().Delete(answersToDelete);
repositoriesContainer.ApplyChanges();
return question;
}
}
示例3: EditObject
public ActionResult EditObject(string name, string path)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
var data = repositoriesContainer.RepositoryFor<ScoObjects>().GetBy(new Query<ScoObjects>(e => e.Path == path));
data.Name = name;
repositoriesContainer.RepositoryFor<ScoObjects>().Save(data);
repositoriesContainer.ApplyChanges();
}
return Json(name, JsonRequestBehavior.AllowGet);
}
示例4: GetRemainingTime
private int GetRemainingTime(int testId, int questionId, int userId)
{
var test = GetTest(testId);
TestPassResult testPassResult = GetTestPassResult(testId, userId);
double seconds = 0;
if (test.SetTimeForAllTest)
{
seconds = (test.TimeForCompleting * 60) - (DateTime.UtcNow - testPassResult.StartTime).TotalSeconds;
}
else
{
if (testPassResult.Comment == questionId.ToString())
{
seconds = test.TimeForCompleting - ((DateTime.UtcNow.Ticks - testPassResult.StartTime.Ticks) / TimeSpan.TicksPerSecond);
}
else
{
seconds = test.TimeForCompleting;
testPassResult.StartTime = DateTime.UtcNow;
testPassResult.Comment = questionId.ToString();
}
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.RepositoryFor<TestPassResult>().Save(testPassResult);
repositoriesContainer.ApplyChanges();
}
}
return seconds > 0 ? (int)seconds : 0;
}
示例5: GetObjects
public ActionResult GetObjects()
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
return Json(repositoriesContainer.RepositoryFor<ScoObjects>().GetAll(new Query<ScoObjects>(e => !e.IsDeleted)).ToList(), JsonRequestBehavior.AllowGet);
}
}
示例6: CheckForTestIsNotLocked
public void CheckForTestIsNotLocked(int testId)
{
var testsQuery = new Query<Test>(test => test.Id == testId)
.Include(t => t.TestUnlocks);
var answersQuery = new Query<AnswerOnTestQuestion>(a => a.TestId == testId);
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
if (repositoriesContainer.TestsRepository.GetBy(testsQuery).TestUnlocks.Count > 0 ||
repositoriesContainer.RepositoryFor<AnswerOnTestQuestion>().GetAll(answersQuery).Count() != 0)
{
throw new InvalidDataException("Тест не может быть изменён, т.к. доступен для прохождения");
}
}
}
示例7: DeleteLecturer
public bool DeleteLecturer(int id)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
var lecturer = repositoriesContainer.LecturerRepository.GetBy(
new Query<Lecturer>(e => e.Id == id).Include(e => e.SubjectLecturers));
if (lecturer != null && lecturer.SubjectLecturers != null)
{
var subjects = lecturer.SubjectLecturers.ToList();
repositoriesContainer.RepositoryFor<SubjectLecturer>().Delete(subjects);
repositoriesContainer.ApplyChanges();
}
}
new LecturerSearchMethod().DeleteIndex(id);
return UserManagementService.DeleteUser(id);
}
示例8: SaveUserLabFiles
public UserLabFiles SaveUserLabFiles(UserLabFiles userLabFiles, IList<Attachment> attachments)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
if (!string.IsNullOrEmpty(userLabFiles.Attachments))
{
var deleteFiles =
repositoriesContainer.AttachmentRepository.GetAll(
new Query<Attachment>(e => e.PathName == userLabFiles.Attachments)).ToList().Where(e => attachments.All(x => x.Id != e.Id)).ToList();
foreach (var attachment in deleteFiles)
{
FilesManagementService.DeleteFileAttachment(attachment);
}
}
else
{
userLabFiles.Attachments = GetGuidFileName();
}
FilesManagementService.SaveFiles(attachments.Where(e => e.Id == 0), userLabFiles.Attachments);
foreach (var attachment in attachments)
{
if (attachment.Id == 0)
{
attachment.PathName = userLabFiles.Attachments;
repositoriesContainer.AttachmentRepository.Save(attachment);
}
}
repositoriesContainer.RepositoryFor<UserLabFiles>().Save(userLabFiles);
repositoriesContainer.ApplyChanges();
}
return userLabFiles;
}
示例9: DeleteLabsVisitingDate
public void DeleteLabsVisitingDate(int id)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
var dateModelmarks =
repositoriesContainer.RepositoryFor<ScheduleProtectionLabMark>()
.GetAll(new Query<ScheduleProtectionLabMark>(e => e.ScheduleProtectionLabId == id))
.ToList();
foreach (var labsVisitMark in dateModelmarks)
{
repositoriesContainer.RepositoryFor<ScheduleProtectionLabMark>().Delete(labsVisitMark);
}
repositoriesContainer.ApplyChanges();
var dateModel =
repositoriesContainer.RepositoryFor<ScheduleProtectionLabs>()
.GetBy(new Query<ScheduleProtectionLabs>(e => e.Id == id));
repositoriesContainer.RepositoryFor<ScheduleProtectionLabs>().Delete(dateModel);
repositoriesContainer.ApplyChanges();
}
}
示例10: SaveScheduleProtectionPracticalDate
public void SaveScheduleProtectionPracticalDate(ScheduleProtectionPractical scheduleProtectionPractical)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.RepositoryFor<ScheduleProtectionPractical>().Save(scheduleProtectionPractical);
repositoriesContainer.ApplyChanges();
}
}
示例11: SaveStudentLabsMark
public void SaveStudentLabsMark(List<StudentLabMark> studentLabMark)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.RepositoryFor<StudentLabMark>().Save(studentLabMark);
repositoriesContainer.ApplyChanges();
}
}
示例12: GetSubGroup
public SubGroup GetSubGroup(int subGroupId)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
return
repositoriesContainer.RepositoryFor<SubGroup>().GetBy(new Query<SubGroup>(e => e.Id == subGroupId)
.Include(e => e.SubjectStudents.Select(x => x.Student.ScheduleProtectionLabMarks)).Include(e => e.SubjectGroup.Group));
}
}
示例13: StartNewTest
private void StartNewTest(int testId, int userId)
{
Test test = GetTest(testId);
int questionsCount = test.CountOfQuestions > test.Questions.Count
? test.Questions.Count
: test.CountOfQuestions;
var random = new Random(DateTime.Now.Millisecond);
IEnumerable<Question> includedQuestions = test.Questions.OrderBy(t => random.Next()).Take(questionsCount);
var answersTemplate = new List<AnswerOnTestQuestion>();
int counter = 1;
foreach (Question includedQuestion in includedQuestions)
{
answersTemplate.Add(new AnswerOnTestQuestion
{
QuestionId = includedQuestion.Id,
TestId = testId,
UserId = userId,
Number = counter++
});
}
TestPassResult testPassResult = GetTestPassResult(testId, userId) ?? new TestPassResult
{
TestId = testId,
StudentId = userId
};
testPassResult.StartTime = DateTime.UtcNow;
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.RepositoryFor<AnswerOnTestQuestion>().Save(answersTemplate);
repositoriesContainer.RepositoryFor<TestPassResult>().Save(testPassResult);
repositoriesContainer.ApplyChanges();
}
}
示例14: SaveMarksCalendarData
public void SaveMarksCalendarData(List<LecturesVisitMark> lecturesVisitMarks)
{
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
repositoriesContainer.RepositoryFor<LecturesVisitMark>().Save(lecturesVisitMarks);
repositoriesContainer.ApplyChanges();
}
}
示例15: GetTestPassResult
private TestPassResult GetTestPassResult(int testId, int userId)
{
TestPassResult result;
using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
{
result =
repositoriesContainer.RepositoryFor<TestPassResult>().GetBy(
new Query<TestPassResult>(res => res.TestId == testId && res.StudentId == userId));
}
return result;
}