public ActionResult SaveFeedBack(FeedBack model) { if (!ModelState.IsValid) { return(PartialView("FeedBack", model)); } if (string.IsNullOrEmpty(model.PhoneNum) && string.IsNullOrEmpty(model.Email) && CurrentUser == null) { ModelState.AddModelError("Email", "Укажите контакты для связи. Email или номер телефона"); ModelState.AddModelError("PhoneNum", "Укажите контакты для связи. Email или номер телефона"); return(PartialView("FeedBack", model)); } var feedBack = new AccountFeedBack() { Description = model.Description, UrlString = model.Url, DateAdd = DateTime.Now, Type = model.FeedType }; if (CurrentUser != null) { feedBack.Contacts = model.Contact; feedBack.AccountId = CurrentUser.Id; } else { feedBack.Contacts = model.ContactNotAuth; } DB.AccountFeedBack.Add(feedBack); DB.SaveChanges(); EmailSender.SendFeedBackMessage(DB, CurrentUser, feedBack.ToString(), Request.UserHostAddress); return(PartialView("Success")); }
public ActionResult AddDomainRequest(AddDomainFeedBack model) { if (!ModelState.IsValid) { return(View(model)); } var feedBack = new AccountFeedBack() { Contacts = model.Contact, Type = (sbyte)FeedBackTypePrivate.AddNewDomainName, UrlString = $"Добавление домена для производителя {model.ProducerName}", Description = $"{model.PresetDescription} {model.Description}", DateAdd = DateTime.Now }; DB.AccountFeedBack.Add(feedBack); DB.SaveChanges(); EmailSender.SendFeedBackMessage(DB, CurrentUser, feedBack.ToString(), Request.UserHostAddress); SuccessMessage("Ваша заявка принята к исполнению"); return(Redirect("~")); }
public ActionResult AddAppointmentRequest(FeedBack model) { if (!ModelState.IsValid) { return(View(model)); } var feedBack = new AccountFeedBack() { Description = model.Description, Type = (sbyte)FeedBackTypePrivate.AddNewAppointment, Contacts = model.Contact, DateAdd = DateTime.Now, UrlString = "Добавление должности", AccountId = CurrentUser.Id }; DB.AccountFeedBack.Add(feedBack); DB.SaveChanges(); EmailSender.SendFeedBackMessage(DB, CurrentUser, feedBack.ToString(), Request.UserHostAddress); SuccessMessage("Ваша заявка принята к исполнению"); return(RedirectToAction("Index", "Profile")); }