public async Task <ActionResult> DeleteConfirmed(int id)
        {
            TopicOfTheDay topicOfTheDay = await db.TopicOfTheDays.FindAsync(id);

            topicOfTheDay.RecLog.DeletedDate = DateTime.Now;
            await db.SaveChangesAsync();

            return(RedirectToAction("Details", "Lessons", new { @id = topicOfTheDay.LessonId }));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Message,SendOnDay,RecLog,LessonId")] TopicOfTheDay topicOfTheDay)
        {
            if (ModelState.IsValid)
            {
                topicOfTheDay.RecLog.CreatedDate = DateTime.Now;
                db.TopicOfTheDays.Add(topicOfTheDay);
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Lessons", new { @id = topicOfTheDay.LessonId }));
            }

            return(View(topicOfTheDay));
        }
        // GET: TopicOfTheDays/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TopicOfTheDay topicOfTheDay = await db.TopicOfTheDays.FindAsync(id);

            if (topicOfTheDay == null)
            {
                return(HttpNotFound());
            }
            return(View(topicOfTheDay));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Message,SendOnDay,RecLog,LessonId")] TopicOfTheDay topicOfTheDay)
        {
            if (ModelState.IsValid)
            {
                var totd = await db.TopicOfTheDays.FirstOrDefaultAsync(it => it.Id == topicOfTheDay.Id);

                if (totd == null)
                {
                    return(View("Error"));
                }

                totd.Message   = topicOfTheDay.Message;
                totd.SendOnDay = topicOfTheDay.SendOnDay;
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Lessons", new { @id = topicOfTheDay.LessonId }));
            }
            return(View(topicOfTheDay));
        }