public async Task Comment(NewCommentModel model) { validator.ValidateAndThrow(model); var user = await userAccess.GetUser(); if (user.Banned) { throw new Exception("Can't post while banned!"); } var newComment = new Dal.Entities.Comment { FileId = model.FileId, Uploader = user.UserName, UploadTime = DateTime.Now, Text = model.Text }; dbContext.Comments.Add(newComment); await dbContext.SaveChangesAsync(); logger.LogInformation(user.Id + ": commented on a file!(ID:" + model.FileId + ")"); }
public async Task <string> Login(LoginModel model) { validator.ValidateAndThrow(model); var result = await signInManager.PasswordSignInAsync(model.Username, model.Password, true, false); if (!result.Succeeded) { throw new Exception("Invalid login!"); } return(await GenerateJwtToken(model)); }