Example #1
0
        public async Task <IActionResult> EntryProcess(ModelCollection model)
        {
            UploadDatetimeModel modeltemp = model.udModel;

            if (modeltemp.strUpload == "" || modeltemp.strUpload == null)
            {
                return(RedirectToAction("Index"));
            }

            DateTime today = DateTime.Now;
            var      user  = await _usermanager.GetUserAsync(User);

            var entry = new Entry()
            {
                ID      = _context.Entries.ToList().Count() + 1,
                Content = modeltemp.strUpload,
                Date    = today,
                User    = user
            };

            _context.Entries.Add(entry);
            _context.SaveChanges();

            return(RedirectToAction(nameof(ScheduleController.Index), "Schedule",
                                    new
            {
                day = today.Day,
                month = today.Month,
                year = today.Year
            }));
        }
        public async Task <IActionResult> EntryProcess(ModelCollection model)
        {
            UploadDatetimeModel modeltemp = model.udModel;

            // view taken care
            // but for precautions
            if (modeltemp.strUpload == "" || modeltemp.strUpload == null)
            {
                return(RedirectToAction(nameof(ScheduleController.Index), "Schedule",
                                        new
                {
                    type = "diary",
                    day = ScheduleController.Exdatetime.Day,
                    month = ScheduleController.Exdatetime.Month,
                    year = ScheduleController.Exdatetime.Year
                }));
            }

            DateTime today = DateTime.Now;
            var      user  = await _usermanager.GetUserAsync(User);

            var entry = new Entry()
            {
                ID      = _context.Entries.ToList().Count() + 1,
                Title   = (modeltemp.Title == null) ? ("Diary on " + DateTime.Now.ToString()) : modeltemp.Title,
                Content = modeltemp.strUpload,
                Date    = today,
                Mood    = modeltemp.Mood,
                User    = user
            };

            _context.Entries.Add(entry);
            _context.SaveChanges();

            return(RedirectToAction(nameof(ScheduleController.Index), "Schedule",
                                    new
            {
                type = "diary",
                day = today.Day,
                month = today.Month,
                year = today.Year
            }));
        }