public virtual ActionResult Create(Feedback model) { ViewBag.FeedbackSubjects = repository.All <FeedbackSubject>(); if (ModelState.IsValid) { try { model.PublishDate = DateTime.UtcNow; this.repository.Insert(model); this.repository.Save(); emailResult result; var admins = Roles.GetUsersInRole(BaseApplication.AdminRole).Select(x => { BaseProfile profile; if (BaseApplication.IsSimpleMembershipProviderConfigured()) { profile = BaseProfile.CreateProfile(this.repository, x); } else { profile = BaseProfile.CreateProfile(x); } return(profile != null ? profile.Email : string.Empty); }).Where(x => !string.IsNullOrEmpty(x)); var subject = this.repository.Find <FeedbackSubject>(model.FeedbackSubjectId).Subject; mailer.Send(string.Join(",", admins), "Feedback submitted", string.Format(@"<h3>A new comment with the category <em>{0}</em> has been posted</h3> <strong>Submitted by</strong>: {1}<br /><strong>Reply to</strong>: {2}<p>{3}</p>", subject, model.Name, model.Email, model.Comment), out result); } catch (Exception ex) { return(HttpStatusCode(System.Net.HttpStatusCode.InternalServerError, ex)); } return(Json(new { success = true, message = FormMessages.FeedbackPostSuccess, content = this.RenderPartialViewToString("list", this.repository.AllIncluding <Feedback>(x => x.FeedbackSubject).OrderByDescending(x => x.PublishDate)) })); } else { return(HttpStatusCode(System.Net.HttpStatusCode.BadRequest, new InvalidOperationException( string.Join("; ", ModelState.Values.SelectMany(x => x.Errors.Select(e => e.ErrorMessage)))))); } }
/// <summary> /// Updates the profile data source with changed profile property values. /// </summary> /// <remarks>If the SimpleMembershipProvider is configured for use, then the /// profile properties will be saved to the associated UserProfile table.</remarks> public override void Save() { if (BaseApplication.IsSimpleMembershipProviderConfigured() && this.repository != null) { var up = this.repository.FindBy <UserProfile>(x => x.UserName == this.UserName).SingleOrDefault(); if (up != null) { up.FirstName = this.FirstName; up.LastName = this.LastName; up.Email = this.Email; this.repository.Update <UserProfile>(up); this.repository.Save(); } } else { base.Save(); } }