internal bool IsValidAddShout(AddShoutBindingModel bindingModel) { if (string.IsNullOrEmpty(bindingModel.Content) || bindingModel.Duration < 1 || bindingModel.Duration > 23) { return(false); } return(true); }
internal void AddShout(AddShoutBindingModel bindingModel, HttpSession currentSession) { User currentUser = this.context.Logins .First(s => s.SessionId == currentSession.Id).User; Shout shout = new Shout() { Content = bindingModel.Content, PostedOn = DateTime.Now, Author = currentUser, Duration = new TimeSpan(0, bindingModel.Duration, 0, 0) }; this.context.Shout.Add(shout); this.context.SaveChanges(); }
public IActionResult Feed(AddShoutBindingModel bindingModel, HttpSession currentSession, HttpResponse response) { if (!this.loginManager.IsAuthenticated(currentSession)) { this.Redirect(response, "/home/feed"); return(null); } if (!this.shoutService.IsValidAddShout(bindingModel)) { this.Redirect(response, "/users/feed"); return(null); } this.shoutService.AddShout(bindingModel, currentSession); this.Redirect(response, "/users/feed"); return(null); }