示例#1
0
        public async Task <ActionResult> Index(GuestBookViewModel model)
        {
            if (ModelState.IsValid)
            {
                ModelState.Clear();

                Task <IProcessResult> appMessageResult;

                if (WeddingCommentBusinessManager.Current.IsSpam(model.NewWeddingComment))
                {
                    model.NewWeddingComment.HiddenFlag = true;

                    appMessageResult = AppMessenger.Current.Send(MessageTypes.SpamWeddingComment,
                                                                 String.Format("<h4>From: {0}</h4><p>{1}</p><br />", model.NewWeddingComment.UserName, model.NewWeddingComment.Comment),
                                                                 "Hidden Comment(s)");

                    ModelState.AddModelError("NewWeddingComment.Comment", "Your comment has been hidden until we can verify it is not an advertisement. Thank you for visiting our website.");
                }
                else
                {
                    appMessageResult = AppMessenger.Current.Send(MessageTypes.NicoleAndJustinWeddingComment,
                                                                 String.Format("<h3>{0}</h3><h4>{1}</h4><p>{2}</p>", model.NewWeddingComment.UserName, model.NewWeddingComment.Email, model.NewWeddingComment.Comment),
                                                                 String.Format("New Wedding Comment from {0}", model.NewWeddingComment.UserName));
                }

                model.NewWeddingComment.WebSiteId = (int)weddingSite;

                await WeddingCommentBusinessManager.Current.InsertAsync(SecurityManager.Current.ConnectionInfo, model.NewWeddingComment);

                await appMessageResult;
            }

            return(await Index());
        }
示例#2
0
        public ActionResult Sign(GuestBookViewModel model, bool captchaValid)
        {
            ViewData["Selected"] = "ContactUs";
            if (ModelState.IsValid)
            {
                if (captchaValid)
                {
                    //BIND GuestBookViewModel to DataObject
                    //NEED TO IMPLEMENT PROPER ORM IN FUTURE!
                    GuestBookContact contact = new GuestBookContact();
                    contact.Contact_Email = model.Contact_Email;
                    contact.Contact_Name  = model.Contact_Name;
                    contact.Comment       = model.Comment;

                    if (_gbServices.Post(contact))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewData["ErrorMessage"] = "An error occured while posting your comment. Please try again.";
                        return(View());
                    }
                }
                else
                {
                    ViewData["ErrorMessage"] = "You did not type the verification word correctly. Please try again.";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
示例#3
0
        public IActionResult GuestBook(GuestBookViewModel guestBook)
        {
            DateTime now = DateTime.Now;

            guestBook.PostDate = new DateTime(1997, now.Month, now.Day, now.Hour, now.Minute, now.Second);
            return(View("../Home/Index"));
        }
示例#4
0
        public async Task <IActionResult> Index(string message, bool?success)
        {
            var _idTestStr = rand.Next(0, TuringTest._vocabulary.Length);
            var _testStr   = TuringTest._vocabulary[_idTestStr];
            var _position  = rand.Next(0, _testStr.Length);
            var _outStr    = _testStr.Substring(0, _position) + "_" + _testStr.Substring(_position + 1);

            var vm = new GuestBookViewModel()
            {
                PublishedGuestMessages = await _context.GuestMessages.Where(x => x.Published).ToListAsync(),

                AllGuestMessages = await _context.GuestMessages.ToListAsync(),

                Message = message,

                Success = success,

                IdTest = _idTestStr,

                TestText = _outStr
            };


            return(View(vm));
        }
        public void DeleteGuestBook(GuestBookViewModel GuestBook)
        {
            GuestBook entity = _guestBookRepository.GetById(GuestBook.Id);

            entity.Status = (int)DbConstant.DefaultDataStatus.Deleted;
            _guestBookRepository.Update(entity);
            _unitOfWork.SaveChanges();
        }
示例#6
0
        //Initialize all Tables

        public GuestBookView()
        {
            InitializeComponent();
            this.ViewModel = new GuestBookViewModel();
            SQLTable1();
            SQLTable2();
            SQLTable3();
        }
示例#7
0
        public IActionResult Index()
        {
            var model = new GuestBookViewModel();

            model.Comments = _guestBook.GetComments();

            return(View(model));
        }
示例#8
0
        public GuestBookDTO ConvertToGuestBookDTO(GuestBookViewModel Model)
        {
            int      id       = 0;
            DateTime date     = Model.PostDate;
            string   message  = Model.Message;
            string   nickname = Model.UserNickName;

            return(new GuestBookDTO(id, date, message, nickname));
        }
        public GuestBookViewModel GetBookWithEntries()
        {
            var guestBookwithEntries = new GuestBookViewModel();

            guestBookwithEntries.allEntries.Add(new GuestEntryViewModel("Tu byłem", "Codecooler", new DateTime(2014, 03, 02, 21, 37, 18)));
            guestBookwithEntries.allEntries.Add(new GuestEntryViewModel("Tutaj nie byłem", "Mentor", new DateTime(2018, 01, 23, 13, 15, 37)));

            return(guestBookwithEntries);
        }
        public ActionResult Index(GuestBook model, int? page) {
            var children = _pageRepository.GetChildren(model).OfType<Comment>();
            //foreach(var child in children) {
            //    child.Metadata.Slug = child.Id;
            //    child.Metadata.Url=child.Id;
            //    _pageRepository.Delete(child);
            //}
            //_pageRepository.SaveChanges();

            var viewModel = new GuestBookViewModel(model, _structureInfo, children) { CurrentPage = page.GetValueOrDefault(0) };
            if (!HttpContext.Request.IsAjaxRequest())
                return View(viewModel);
            return PartialView("CommentList", viewModel);
        }
示例#11
0
        public async Task <ActionResult> Index()
        {
            GuestBookViewModel model = new GuestBookViewModel();

            model.WeddingComments = await WeddingCommentBusinessManager.Current.SelectAsync(SecurityManager.Current.ConnectionInfo, new WeddingComment()
            {
                WebSiteId  = (int)weddingSite,
                HiddenFlag = false
            });

            model.WeddingComments = model.WeddingComments.OrderByDescending(wc => wc.InsertedOn);

            return(View("GuestBook", model));
        }
示例#12
0
        public void UpdateGuestBook(GuestBookViewModel guestBook, int userId)
        {
            DateTime serverTime = DateTime.Now;

            guestBook.ModifyDate   = serverTime;
            guestBook.ModifyUserId = userId;

            GuestBook entity = _guestBookRepository.GetById(guestBook.Id);

            Map(guestBook, entity);

            _guestBookRepository.AttachNavigation <Vehicle>(entity.Vehicle);
            _guestBookRepository.Update(entity);

            _unitOfWork.SaveChanges();
        }
示例#13
0
        public void InsertGuestBook(GuestBookViewModel guestBook, int userId)
        {
            DateTime serverTime = DateTime.Now;

            guestBook.CreateDate   = serverTime;
            guestBook.CreateUserId = userId;
            guestBook.ModifyDate   = serverTime;
            guestBook.ModifyUserId = userId;
            guestBook.Status       = (int)DbConstant.DefaultDataStatus.Active;


            GuestBook entity = new GuestBook();

            Map(guestBook, entity);
            _guestBookRepository.AttachNavigation <Vehicle>(entity.Vehicle);
            _guestBookRepository.Add(entity);

            _unitOfWork.SaveChanges();
        }
示例#14
0
        public async Task <IActionResult> AddMessage(GuestBookViewModel vm, IFormFile File)
        {
            if (vm.OutTestText != TuringTest._vocabulary[vm.IdTest])
            {
                return(RedirectToAction("Index", new { message = "Ошибка! Тест Тьюринга не пройден!", success = false }));
            }
            if (ModelState.IsValid)
            {
                if (File != null)
                {
                    var filePath = _hostingEnvironment.WebRootPath;
                    filePath = Path.Combine(filePath, "Files");
                    filePath = Path.Combine(filePath, File.FileName);
                    using (var fileStream = new FileStream(filePath, FileMode.Create))
                    {
                        await File.CopyToAsync(fileStream);
                    }
                }
                else
                {
                    vm.GuestMessage.ImagePath = "/Files/default.png";
                }
                vm.GuestMessage.Date      = DateTime.Now;
                vm.GuestMessage.Published = false;
                await _context.GuestMessages.AddAsync(vm.GuestMessage);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index",
                                        new
                {
                    message = "Сообщение добавлено! Идентификатор сообщения " + vm.GuestMessage.Id.ToString(),
                    success = true
                }));
            }
            else
            {
                return(RedirectToAction("Index", new { message = "Сообщение не удалось добавить!", success = false }));
            }
        }
        public IActionResult Index(int offset = 1)
        {
            int maxPerPage  = 10;
            int total       = _db.GuestbookItem.Take(1000).ToArray().Length;
            int queryOffset = maxPerPage * (offset - 1);

            GuestbookItem[] gbItems = _db.GuestbookItem.OrderByDescending(x => x.Created)
                                      .Skip(queryOffset)
                                      .Take(maxPerPage)
                                      .ToArray();
            ViewBag.HaveData = gbItems.Length > 0;

            Pager pagination = new Pager(total, offset, maxPerPage);

            ViewBag.Pagination = pagination;

            GuestBookViewModel viewModel = new GuestBookViewModel {
                GuestbookItems = gbItems,
                Pagination     = pagination
            };

            return(View(viewModel));
        }
示例#16
0
 public GuestHandler(GuestBookViewModel gvm)
 {
     this.Gvm = gvm;
 }
 public IActionResult Index()
 {
     guestBook = GetBookWithEntries();
     return(View(guestBook));
 }
示例#18
0
 // `vm` will be injected by stylet IoC
 public ShellViewModel(GuestBookViewModel vm)
 {
     ActiveItem = vm;
 }