public ActionResult Create(iDiary iDiary)
        {
            iDiary.Appointments[0].CreatedBy = iDiary.Reminders[0].ClientPersonnelID;
            try
            {
                if (iDiary.AddDiaryAppointment())
                {
                    ModelState.Clear();
                    iDiary.Appointments.Clear();
                    iDiary.Reminders.Clear();
                    iDiary.ReminderValues = new List<string>();
                    iDiary.Appointments = new List<DiaryAppointment>();
                    iDiary.Reminders = new List<AquariumDiaryManagement.Reminder>();
                    iDiary.DiaryTexts.AllDiaryTexts = new List<DiaryText>();
                    iDiary.DiaryTitles.AllDiaryTitles = new List<DiaryTitle>();

                    iDiary.Appointments.Add(new DiaryAppointment());
                    iDiary.Reminders.Add(new AquariumDiaryManagement.Reminder());

                    iDiary.Appointments[0].EndDate = DateTime.Now.AddDays(7);
                    iDiary.Appointments[0].DueDate = DateTime.Now;

                    iDiary.GetAllLeads();
                    iDiary.GetAllUsers();
                    iDiary.GetAllTimeshiftValues();
                    iDiary.GetAllDiaryTitles();
                    iDiary.GetDefaultDiaryText();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return View(iDiary);
        }
        public ActionResult Edit(iDiary iDiary)
        {
            iDiary.Appointments[0].CreatedBy = iDiary.Reminders[0].ClientPersonnelID;

            try
            {
                if (iDiary.AddDiaryAppointment())
                {
                    iDiary.AddDiaryLog(iDiary.Appointments[0].DiaryAppointmentID, 3, DateTime.Now, iDiary.Appointments[0].CreatedBy, "Task Updated");
                    iDiary.GetAllLeads();
                    iDiary.GetAllUsers();
                    iDiary.GetAllTimeshiftValues();
                    iDiary.GetAllDiaryTitles();
                    iDiary.GetDefaultDiaryText();
                    iDiary.GetAllDiaryLogsbyID(iDiary.Appointments[0].DiaryAppointmentID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return View(iDiary);
        }
        public ActionResult Complete(int id)
        {
            iDiary Diary = new iDiary();

            try
            {
                if (Diary.GetAppointmentbyID(id))
                {
                    Diary.Appointments[0].Completed = true;
                    Diary.Appointments[0].EndDate = DateTime.Now;

                    Diary.AddDiaryAppointment();
                    Diary.AddDiaryLog(Diary.Appointments[0].DiaryAppointmentID, 5, DateTime.Now, Diary.Appointments[0].CreatedBy, "Task Completed");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return RedirectToAction("Index", "iDiary");
        }