public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzmateMsgModel>(modelParam.ToString()); if (model == null) { return(null); } QuizzmateMsg1 entity = null; model.MapToNew(out entity); _uow.QuizzmateMsg1s.Add(entity); _uow.SaveChanges(); model = MappingUtil.Map <QuizzmateMsg1, QuizzmateMsgModel>(entity); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public bool UpdateNotifications(DependentNotificationModel model) { try { var dependentEntity = _uow.Dependents.GetAll() .Where(d => d.ChildId == model.ChildId && d.UserId == _currentUser.Id) .FirstOrDefault(); if (dependentEntity != null) { var entity = MappingUtil.Map <DependentNotificationModel, Dependent>(model); entity.Id = dependentEntity.Id; entity.IsPrimary = dependentEntity.IsPrimary; entity.UserId = dependentEntity.UserId; entity.ChildId = dependentEntity.ChildId; _uow.Dependents.Detach(dependentEntity); _uow.Dependents.Update(entity); _uow.SaveChanges(); } return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
// resend request public bool Patch(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassJoinRequestModel>(modelParam.ToString()); if (model == null) { return(false); } var entity = _uow.QuizzClassJoinRequests.GetAll() .Where(qcj => qcj.QuizzClassId == model.QuizzClassId && qcj.UserId == _currentUser.Id) .FirstOrDefault(); entity.PostedDate = DateTime.UtcNow; entity.IsNew = true; _uow.QuizzClassJoinRequests.Update(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <AssignmentModel>(modelParam.ToString()); if (model == null) { return(null); } Assignment entity; model.MapToNew <AssignmentModel, Assignment>(out entity); entity.AssignmentGroup = null; entity.CompletedDate = DateTime.UtcNow;; _uow.Assignments.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public bool CreateComment(QuizzCommentModel model) { try { model.AuthorId = _currentUser.Id; model.PostedDate = DateTime.UtcNow; var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Add(entity); _notificationSvc.QuizzNotificationSvc.AddQuizzCommentNotification(model.QuizzId, false); _uow.SaveChanges(); model.Id = entity.Id; model.AuthorName = _currentUser.UserName; model.PostedDate = entity.PostedDate; _notificationSvc.DepQuizzCommentNotificationSvc.AddDepPostCommentNotification(model.Id, false); _notificationSvc.DepQuizzNotificationSvc.AddDepQuizzReceiveCommentNotification(model.QuizzId, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzCommentCreateActivity(model.QuizzId, model.Id, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzReceiveCommentActivity(model.QuizzId, model.Id, false); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public bool UpdateQuestion(QAQuestionModel model) { try { var entity = MappingUtil.Map <QAQuestionModel, QandAQuestion>(model); entity.Answers = null; if (entity.AddContentType == AddContentTypeEnum.PictureOnly && model.IsImageChanged) { string tmpString; ImageUtil.SaveImage("Test_" + model.TestId.ToString(), model.NewImageFileName, "", model.ImageContent, out tmpString, true); entity.ImageUrl = tmpString; } _uow.QandAQuestions.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassAnnouncementModel>(modelParam.ToString()); if (model == null) { return(null); } QuizzClassAnnouncement entity; model.MapToNew(out entity); entity.PostedDate = DateTime.UtcNow; _uow.QuizzClassAnnouncements.Add(entity); _svcContainer.QuizzClassMemberUpdateSvc.AddAnnouncement(model.QuizzClassId, false); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public QuizzModel GetQuizzById(int id) { try { QuizzModel model = null; var entity = _uow.Quizzes.GetAll() .Include(q => q.Tests) .Include(q => q.Reviewers) .Where(q => q.Id == id && q.IsDeleted == false) .FirstOrDefault(); if (entity != null) { model = MappingUtil.Map <Quizz, QuizzModel>(entity); } model.ReviewerId = entity.Reviewers.FirstOrDefault().Id; model.TestId = entity.Reviewers.FirstOrDefault().Id; return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
private bool CreateQuestion(QAQuestionModel model) { try { var entity = MappingUtil.Map <QAQuestionModel, QandAQuestion>(model); entity.AuthorId = _currentUser.Id; entity.Question = ""; if (entity.AddContentType == AddContentTypeEnum.PictureOnly) { string tmpString; ImageUtil.SaveImage("Test_" + model.TestId.ToString(), model.NewImageFileName, "", model.ImageContent, out tmpString); entity.ImageUrl = tmpString; } _uow.QandAQuestions.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); model.Question = model.TextContent; return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <FriendRequestModel>(modelParam.ToString()); if (model == null) { return(null); } FriendRequest entity; model.MapToNew <FriendRequestModel, FriendRequest>(out entity); entity.RequestFromId = _currentUser.Id; entity.IsNew = true; entity.IsAccepted = null; entity.PostedDate = DateTime.UtcNow; _uow.FriendRequests.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); _svcContainer.NotificationSvc.DepQuizzmateNotificationSvc.AddDepQuizzmateReceiveRequestNotification(entity, false); _svcContainer.NotificationSvc.DepQuizzmateNotificationSvc.AddDepQuizzmateSendRequestNotification(entity, false); _svcContainer.RelationshipNotificationSvc.QuizzmateNotificationSvc.AddQuizzmateRequestRNotification(entity, true); _svcContainer.EmailSvc.SendQuizzmateRequest(entity); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassLessonModel>(modelParam.ToString()); if (model == null) { return(null); } var parent = _uow.QuizzClasses.GetById(model.QuizzClassId); QuizzClassLesson entity; model.MapToNew(out entity); entity.QuizzClassLesssonIdx = parent.QuizzClassLessonIdx++; _uow.QuizzClasses.Update(parent); _uow.QuizzClassLessons.Add(entity); _svcContainer.QuizzClassMemberUpdateSvc.AddClassLesson(entity.QuizzClassId, false); _uow.SaveChanges(); entity.Comments = new List <QuizzClassLessonComment>(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
// request quizzling public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <DependentRequestFromUserModel>(modelParam.ToString()); if (model == null) { return(null); } DependentRequestFromUser entity; model.MapToNew(out entity); entity.FromUserId = _currentUser.Id; _uow.DependentRequestsFromUser.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); _svcContainer.RelationshipNotificationSvc.QuizzlingNotificationSvc.AddQuizzlingRequestRNotification(entity, true); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public MultiChoiceSameQuestionModel GetQuestionById(int id) { var entity = _uow.MultiChoiceSameQuestions.GetAll() .Include(q => q.ChoiceGroup.Choices) .Where(q => q.Id == id) .FirstOrDefault(); var model = MappingUtil.Map <MultiChoiceSameQuestion, MultiChoiceSameQuestionModel>(entity); return(model); }
public bool CreateChoice(MultiChoiceSameChoiceModel model) { var entity = MappingUtil.Map <MultiChoiceSameChoiceModel, MultiChoiceSameChoice>(model); _uow.MultiChoiceSameChoices.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public TextFlashCardModel GetTextFlashCardById(int id) { TextFlashCardModel model = null; var entity = _uow.TextFlashCards.GetById(id); if (entity != null) { model = MappingUtil.Map <TextFlashCard, TextFlashCardModel>(entity); } return(model); }
public bool CreateTestSetting(TestSettingModel model) { var entity = MappingUtil.Map <TestSettingModel, TestSetting>(model); _uow.TestSettings.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
// Get Not needed: QAQuestion will already get them thru DB Call public bool CreateAnswer(QAAnswerModel model) { var entity = MappingUtil.Map <QAAnswerModel, QandAAnswer>(model); _uow.QandAAnswers.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public TestSettingModel GetTestSetting(int id) { TestSettingModel model = null; var entity = _uow.TestSettings.GetById(id); if (entity != null) { model = MappingUtil.Map <TestSetting, TestSettingModel>(entity); } return(model); }
public QuickNoteModel GetQuickNoteById(int id) { QuickNoteModel model = null; var entity = _uow.QuickNotes.GetById(id); if (entity != null) { model = MappingUtil.Map <QuickNote, QuickNoteModel>(entity); } return(model); }
public bool UpdateAnswer(QAAnswerModel model) { var entity = MappingUtil.Map <QAAnswerModel, QandAAnswer>(model); try { _uow.QandAAnswers.Update(entity); _uow.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public bool UpdateTestSetting(TestSettingModel model) { var entity = MappingUtil.Map <TestSettingModel, TestSetting>(model); try { _uow.TestSettings.Update(entity); _uow.SaveChanges(); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } return(true); }
public bool UpdateComment(QuizzCommentModel model) { try { var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public bool UpdateTextFlashCard(TextFlashCardModel model) { try { var entity = MappingUtil.Map <TextFlashCardModel, TextFlashCard>(model); _uow.TextFlashCards.Update(entity); _uow.SaveChanges(); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } return(true); }
public bool UpdateChoiceGroup(MultiChoiceSameChoiceGroupModel model) { try { var entity = MappingUtil.Map <MultiChoiceSameChoiceGroupModel, MultiChoiceSameChoiceGroup>(model); _uow.MultiChoiceSameChoiceGroups.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public bool UpdatePermissions(DependentPermissionModel model) { try { var entity = MappingUtil.Map <DependentPermissionModel, DependentPermission>(model); _uow.DependentPermissions.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public bool UpdateQuickNote(QuickNoteModel model) { try { var entity = MappingUtil.Map <QuickNoteModel, QuickNote>(model); _uow.QuickNotes.Update(entity); _uow.SaveChanges(); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } return(true); }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <AssignmentGroupModel>(modelParam.ToString()); if (model == null) { return(null); } AssignmentGroup assignmentGroup; model.MapToNew <AssignmentGroupModel, AssignmentGroup>(out assignmentGroup); assignmentGroup.AssignedById = _currentUser.Id; assignmentGroup.DateAssigned = DateTime.UtcNow; if (assignmentGroup.NoDueDate) { assignmentGroup.TargetDate = new DateTime(2050, 01, 01); } foreach (var item in assignmentGroup.Assignments) { item.TestResultId = 1; item.IsCompleted = false; item.CompletedDate = DateTime.UtcNow; } _uow.AssignmentGroups.Add(assignmentGroup); _uow.SaveChanges(); MappingUtil.Map(assignmentGroup, model); foreach (var item in assignmentGroup.Assignments) { _notificationSvc.AssignmentNotificationSvc.AddAssignmentAssignedNotification(assignmentGroup.QuizzId, assignmentGroup.Id, item.Id, item.DependentId, false); } _uow.SaveChanges(); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public QAQuestionModel GetQuestionById(int id) { QAQuestionModel model = null; var entity = _uow.QandAQuestions.GetAll() .Include(q => q.Answers) .Where(q => q.Id == id) .FirstOrDefault(); if (entity != null) { model = MappingUtil.Map <QandAQuestion, QAQuestionModel>(entity); } UpdateModel(model); return(model); }
// Get Not needed: MCChoice will already get them thru DB Call public bool CreateChoice(MChoiceModel model) { try { var entity = MappingUtil.Map <MChoiceModel, MultipleChoiceChoice>(model); _uow.MultipleChoiceChoices.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public TakeTestModel GetTakeTestModel(int id) { var entity = _questionTypeSvc.GetTestEntityWithAnswers(id); if (entity == null) { return(null); } var model = MappingUtil.Map <Test, TakeTestModel>(entity); foreach (var item in model.Questions) { item.QuestionViewType = Enums.QuestionViewTypeEnum.Tinymce; } return(model); }