public async Task <ResponseMessage> VerifyPhoneCode(UserVerifyPhoneCodeViewModel model) { var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code); if (result.Succeeded) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.VerifyPhoneCodeRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Code }, { LogProperties.Message, ErrorMessages.Successful }, { LogProperties.AdditionalData, model.PhoneNumber } }); return(Tools.ResponseMessage.Ok); } // If we got this far, something failed, redisplay form LogThis.BaseLog(Request, LogLevel.Warn, Actions.VerifyPhoneCodeRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Code }, { LogProperties.Message, ErrorMessages.VerificationCodeInvalid }, { LogProperties.AdditionalData, model.PhoneNumber } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.AuthenticationFailed, ErrorMessages.VerificationCodeInvalid)); }
public async Task <ResponseMessage> BugReport(BugReportViewModel bug) { try { LogThis.BaseLog(Request, LogLevel.Info, Actions.BugReported, new Dictionary <LogProperties, object> { { LogProperties.AdditionalData, bug.Bug }, { LogProperties.Message, ErrorMessages.Successful } }); _db.BugReports.Add(new BugReport { DateTime = DateTime.Now, UserId = User.Identity.GetUserId(), Text = bug.Bug }); await _db.SaveChangesAsync(); return(Tools.ResponseMessage.Ok); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.BugReported, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public ResponseMessage ProfileData() { try { var userId = User.Identity.GetUserId(); var user = _db.Users.Find(userId); LogThis.BaseLog(Request, LogLevel.Info, Actions.ProfileDataRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, userId }, { LogProperties.IdType, typeof(ApplicationUser) }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(new ProfileViewModel(user))); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.ProfileDataRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> UserBoxQuestions(IdRequestViewModel model) {//id userpackagebox try { var userPackageBox = await db.UserPackageBoxes.FindAsync(model.Id); if (userPackageBox == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.UserPackageBoxNotFound } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.UserPackageBoxNotFound)); } switch (userPackageBox.State) { case BoxState.NotOwned: LogThis.BaseLog(Request, LogLevel.Info, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.UserNotOwnedBox }, }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.UserStatusFaild, ErrorMessages.UserNotOwnedBox)); case BoxState.Learning: LogThis.BaseLog(Request, LogLevel.Info, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.UserPackageBoxNotLearned } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.UserStatusFaild, ErrorMessages.UserPackageBoxNotLearned)); default: LogThis.BaseLog(Request, LogLevel.Info, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.Successful }, { LogProperties.Count, userPackageBox.Box.Articles.Count } }); return(Tools.ResponseMessage.OkWithResult(userPackageBox.Box.Articles.SelectMany(x => x.Questions).Select(x => new QuestionMinimalViewModel(x, User.Identity.GetUserId())))); } } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> LeaderBoard() { try { const int topN = 10; var user = _db.Users.Find(User.Identity.GetUserId()); var userOrder = await _db.Users.CountAsync(x => x.Score > user.Score); ScoreBoardItemViewModel userItem = null; if (userOrder >= topN) //user is not in topN { userItem = new ScoreBoardItemViewModel { Score = user.Score, Name = user.UserName, Order = userOrder }; } var y = await _db.Users.OrderByDescending(x => x.Score).Take(topN).ToListAsync().ConfigureAwait(false); var items = y.Select((x, i) => new ScoreBoardItemViewModel { Score = x.Score, Name = x.UserName, Order = i + 1 }).ToList(); var challenge = await _db.Challenges.OrderByDescending(x => x.Finish).FirstOrDefaultAsync(); var result = new ScoreBoardViewModel { Items = items, UserItem = userItem, Challenge = challenge }; LogThis.BaseLog(Request, LogLevel.Info, Actions.LeaderBoardRequested, new Dictionary <LogProperties, object> { { LogProperties.AdditionalData, $"رتبه کاربر {userOrder} میباشد" }, { LogProperties.Id, challenge?.Id }, { LogProperties.IdType, challenge?.GetType() }, { LogProperties.Count, items.Count }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(result)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.LeaderBoardRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> SetAvatar(IdRequestViewModel avatarId) { try { var avatar = await _db.AvatarImages.FindAsync(avatarId.Id); if (avatar == null) { LogThis.BaseLog(Request, LogLevel.Info, Actions.SetAvatarRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, avatarId.Id }, { LogProperties.IdType, typeof(AvatarImage) }, { LogProperties.Message, ErrorMessages.AvatarImageNotFound } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.AvatarImageNotFound)); } var user = _db.Users.Find(User.Identity.GetUserId()); user.AvatarImage = avatar; await _db.SaveChangesAsync(); LogThis.BaseLog(Request, LogLevel.Info, Actions.SetAvatarRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, avatarId.Id }, { LogProperties.IdType, typeof(AvatarImage) }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.Ok); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.SetAvatarRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> Packages(IdRequestViewModel model) { string ip = StaticTools.GetIp(Request); string userId = User.Identity.GetUserId(); try { var category = await db.Catergories.FindAsync(model.Id); if (category == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.PackagesOfCategoryRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.RequestedCategoryNotFound } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.RequestedCategoryNotFound)); } var result = category.Packages.Select(x => new PackageMinimalViewModel(x, userId)).ToList(); LogThis.BaseLog(Request, LogLevel.Info, Actions.PackagesOfCategoryRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Count, result.Count }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(result)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.CategoriesRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> Categories() { //string ip = StaticTools.GetIp(Request); try { var result = await db.Catergories.ToListAsync(); LogThis.BaseLog(Request, LogLevel.Info, Actions.CategoriesRequested, new Dictionary <LogProperties, object> { { LogProperties.Count, result.Count }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(result)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.CategoriesRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> UserPackageBoxes(IdRequestViewModel model) { var z = UserManager.GenerateUserToken("sss", User.Identity.GetUserId()); try { var package = await db.Packages.FindAsync(model.Id); if (package == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.PackageBoxesRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.PackageNotFound } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.PackageNotFound)); } var userId = User.Identity.GetUserId(); var packageBoxes = package.Boxes.Select(x => new UserBoxMinimalViewModel(x, userId)).ToList(); LogThis.BaseLog(Request, LogLevel.Info, Actions.PackageBoxesRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.Id }, { LogProperties.Message, ErrorMessages.Successful }, { LogProperties.Count, packageBoxes.Count } }); return(Tools.ResponseMessage.OkWithResult(packageBoxes)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.CategoriesRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> ProfileImagesList() { try { var avatarImages = await _db.AvatarImages.ToListAsync(); LogThis.BaseLog(Request, LogLevel.Info, Actions.ProfileImageListRequested, new Dictionary <LogProperties, object> { { LogProperties.Count, avatarImages.Count }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(avatarImages)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.ProfileImageListRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> MyPackages() { try { var userId = User.Identity.GetUserId(); var user = await UserManager.FindByIdAsync(userId); var userPackages = user.UserPackages; LogThis.BaseLog(Request, LogLevel.Info, Actions.PackagesOfUserRequested, new Dictionary <LogProperties, object> { { LogProperties.Count, userPackages?.Count }, { LogProperties.Message, ErrorMessages.Successful } }); return(Tools.ResponseMessage.OkWithResult(userPackages?.Select(x => new UserPackageMinimalViewModel(x, userId)))); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.CategoriesRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> LearnedArticle(LearningViewModel model) { try { var userId = User.Identity.GetUserId(); var userPackageBox = await db.UserPackageBoxes.FirstOrDefaultAsync(x => x.BoxId == model.BoxId && x.UserPackage.UserId == userId); //var userPackageBox = await db.UserPackageBoxes.FindAsync(model.UserBoxId); if (userPackageBox == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.LearnedArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.UserPackageBoxNotFound }, { LogProperties.AdditionalData, model.Order } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.UserPackageBoxNotFound)); } if (userPackageBox.State == BoxState.NotOwned) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.LearnedArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.UserNotOwnedBox }, { LogProperties.AdditionalData, model.Order }, { LogProperties.State, BoxState.NotOwned } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.UserStatusFaild, ErrorMessages.UserNotOwnedBox)); } var articles = userPackageBox.Box.Articles.ToList(); var article = articles.FirstOrDefault(x => x.Order == model.Order); if (article == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.LearnedArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.ArticleNotFound }, { LogProperties.AdditionalData, model.Order } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.ArticleNotFound)); } var articleIndex = articles.IndexOf(article) + 1; if (userPackageBox.State != BoxState.Learning || articleIndex <= userPackageBox.StateValue) { LogThis.BaseLog(Request, LogLevel.Info, Actions.LearnedArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.ArticleLearnRepeated }, { LogProperties.AdditionalData, model.Order }, { LogProperties.State, userPackageBox.State } }); return(Tools.ResponseMessage.OkWithMessage(ErrorMessages.ArticleLearnRepeated)); //todo: review this message is correct? } db.Users.Find(userId).AddScore(ScoreReason.ArticleRead); LogThis.BaseLog(Request, LogLevel.Info, Actions.ChangeBoxStateValue, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.ArticleLearned }, { LogProperties.AdditionalData, model.Order }, { LogProperties.State, userPackageBox.State }, { LogProperties.From, userPackageBox.StateValue }, { LogProperties.To, articleIndex } }); userPackageBox.StateValue++; if (userPackageBox.Box.Articles.Count == userPackageBox.StateValue) { LogThis.BaseLog(Request, LogLevel.Info, Actions.ChangeBoxState, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.UserBoxStateChanged }, { LogProperties.AdditionalData, model.Order }, { LogProperties.From, BoxState.Learning }, { LogProperties.To, BoxState.Examing } }); userPackageBox.State = BoxState.Examing; LogThis.BaseLog(Request, LogLevel.Info, Actions.ChangeBoxStateValue, new Dictionary <LogProperties, object> { { LogProperties.Id, userPackageBox.Id }, { LogProperties.IdType, typeof(UserPackageBox) }, { LogProperties.Message, ErrorMessages.UserBoxStateValueChange }, { LogProperties.AdditionalData, model.Order }, { LogProperties.State, userPackageBox.State }, { LogProperties.From, userPackageBox.StateValue }, { LogProperties.To, 0 } }); userPackageBox.StateValue = 0; db.SaveChanges(); return(Tools.ResponseMessage.OkWithMessage(ErrorMessages.UserBoxStateChanged)); } db.SaveChanges(); return(Tools.ResponseMessage.OkWithMessage(ErrorMessages.ArticleLearned)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> QuestionViewed(QuestionReviewingViewModel model) { try { var question = await db.Questions.FindAsync(model.QuestionId); if (question == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.QuestionId }, { LogProperties.IdType, typeof(Question) }, { LogProperties.Message, ErrorMessages.QuestionNotFound }, { LogProperties.AdditionalData, model.BoxId } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.QuestionNotFound)); } var box = await db.Boxes.FindAsync(model.BoxId); if (box == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.PackageBoxNotFound }, { LogProperties.AdditionalData, model.QuestionId } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.PackageBoxNotFound)); } var userPackageBox = box.UserPackageBoxes.FirstOrDefault(x => x.UserPackage.UserId == User.Identity.GetUserId()); if (userPackageBox == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.UserPackageBoxNotFound }, { LogProperties.AdditionalData, model.QuestionId } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.UserPackageBoxNotFound)); } if (userPackageBox.State != BoxState.Examing) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.UserPackageBoxStateIncorrect }, { LogProperties.AdditionalData, model.QuestionId } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.UserPackageBoxStateIncorrect)); } int index = box.Articles.ToList().IndexOf(question.Article); if (index == -1) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.QuestionNotInThisBox }, { LogProperties.AdditionalData, model.QuestionId } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.QuestionNotInThisBox)); } LogThis.BaseLog(Request, LogLevel.Info, Actions.QuestionViewdRequested, new Dictionary <LogProperties, object> { { LogProperties.Id, model.BoxId }, { LogProperties.IdType, typeof(Box) }, { LogProperties.Message, ErrorMessages.Successful }, { LogProperties.From, userPackageBox.StateValue }, { LogProperties.To, index + 1 }, { LogProperties.AdditionalData, model.QuestionId } }); userPackageBox.StateValue = index + 1; await db.SaveChangesAsync(); return(Tools.ResponseMessage.OkWithMessage(ErrorMessages.Successful)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }
public async Task <ResponseMessage> AnsweringArticle(AnsweringViewModel model) { try { var userId = User.Identity.GetUserId(); var answer = await db.Answers.FindAsync(model.AnswerId); if (answer == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.AnswerNotFound }, }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.AnswerNotFound)); } var userPackageBox = answer.Question.Article.Box.UserPackageBoxes.FirstOrDefault(x => x.UserPackage.UserId == userId); if (userPackageBox == null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.UserPackageBoxNotFound }, }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.NotFound, ErrorMessages.UserPackageBoxNotFound)); } if (userPackageBox.State != BoxState.Examing) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.UserPackageBoxStateIncorrect }, { LogProperties.From, userPackageBox.State.ToString() }, { LogProperties.To, BoxState.Examing.ToString() } }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.UserStatusFaild, ErrorMessages.UserPackageBoxStateIncorrect)); } UserAnswer userAnswer = answer.Question.UserAnswers.FirstOrDefault(x => x.UserId == userId); if (userAnswer != null) { LogThis.BaseLog(Request, LogLevel.Warn, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.UserAnswerdBefore }, }); return(new ResponseMessage(Tools.ResponseMessage.ResponseCode.Expire, ErrorMessages.UserAnswerdBefore)); } answer.Question.UserAnswers.Add(new UserAnswer() { AnswerId = answer.Id, DateTime = DateTime.Now, UserId = userId }); var user = db.Users.Find(userId); var reason = answer.IsCorrect ? ScoreReason.CorrectAnswer : ScoreReason.WrongAnswer; user.AddScore(reason); await db.SaveChangesAsync(); if (userPackageBox.Box.Articles.SelectMany(x => x.Questions).Select(x => new QuestionMinimalViewModel(x, User.Identity.GetUserId())).All(x => x.UserAnswerId != null)) { LogThis.BaseLog(Request, LogLevel.Info, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.UserBoxStateChanged }, { LogProperties.From, BoxState.Examing.ToString() }, { LogProperties.To, BoxState.Finished.ToString() } }); LogThis.BaseLog(Request, LogLevel.Info, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, ErrorMessages.UserBoxStateValueChange }, { LogProperties.From, userPackageBox.StateValue }, { LogProperties.To, 0 } }); userPackageBox.StateValue = 0; userPackageBox.State = BoxState.Finished; await db.SaveChangesAsync(); } LogThis.BaseLog(Request, LogLevel.Info, Actions.AnsweredArticle, new Dictionary <LogProperties, object> { { LogProperties.Id, model.AnswerId }, { LogProperties.IdType, typeof(Answer) }, { LogProperties.Message, answer.IsCorrect ? ErrorMessages.CorrectAnswer : ErrorMessages.WrongAnswer }, }); return(Tools.ResponseMessage.OkWithMessage(answer.IsCorrect ? ErrorMessages.CorrectAnswer : ErrorMessages.WrongAnswer)); } catch (Exception e) { LogThis.BaseLog(Request, LogLevel.Error, Actions.UserPackageBoxQuestionsRequested, new Dictionary <LogProperties, object> { { LogProperties.Error, e } }); return(Tools.ResponseMessage.InternalError); } }