Example #1
0
        //public static bool CreateNewEvent(string NewEventDate, string NewEventStart, string NewEventEnd)
        //{
        //    try
        //    {
        //        ApplicationDbContext ent = new ApplicationDbContext();
        //        SchedulingDiary rec = new SchedulingDiary();

        //        //strat timing
        //        DateTime timestartSat = DateTime.Parse(NewEventStart);
        //        string newstartSat = timestartSat.ToString("hh:mm");
        //        string newslotstartSat = timestartSat.ToString("tt");

        //        //End timing
        //        DateTime timeendSat = DateTime.Parse(NewEventEnd);
        //        string newsendSat = timeendSat.ToString("hh:mm");
        //        string newsslotendSat = timeendSat.ToString("tt");


        //        rec.LoginId = 4;

        //        rec.DateTimeScheduled = DateTime.ParseExact(NewEventDate, "dd/MM/yyyy", null);
        //        rec.StartTime = TimeSpan.Parse(newstartSat);
        //        rec.EndTime = TimeSpan.Parse(newsendSat);
        //        rec.StartSlot = newslotstartSat;
        //        rec.EndSlot = newsslotendSat;
        //        ent.SchedulingDiarys.Add(rec);
        //        ent.SaveChanges();
        //    }
        //    catch (Exception)
        //    {
        //        return false;
        //    }
        //    return true;
        //}


        public static bool CreateNewEvent(string NewEventDate, string NeweventStartTime, string NeweventEndTime, string NewCurrentDate)
        {
            try
            {
                ApplicationDbContext ent = new ApplicationDbContext();
                SchedulingDiary      rec = new SchedulingDiary();

                // strat timing
                DateTime timestartSat    = DateTime.Parse(NeweventStartTime);
                string   newstartSat     = timestartSat.ToString("hh:mm");
                string   newslotstartSat = timestartSat.ToString("tt");

                //End timing
                DateTime timeendSat     = DateTime.Parse(NeweventEndTime);
                string   newsendSat     = timeendSat.ToString("hh:mm");
                string   newsslotendSat = timeendSat.ToString("tt");

                DateTime dt = DateTime.ParseExact(NewEventDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                rec.Title             = dt.DayOfWeek.ToString();
                rec.DateTimeScheduled = DateTime.ParseExact(NewEventDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                rec.StartTime         = TimeSpan.Parse(newstartSat);
                rec.StartSlot         = newslotstartSat;
                rec.EndTime           = TimeSpan.Parse(newsendSat);
                rec.EndSlot           = newsslotendSat;
                ent.SchedulingDiarys.Add(rec);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Example #2
0
        public static bool DeleteDiaryEvent(string NewDeleteEventId)
        {
            try
            {
                using (ApplicationDbContext ent = new ApplicationDbContext())
                {
                    int             id  = Convert.ToInt32(NewDeleteEventId);
                    SchedulingDiary rec = ent.SchedulingDiarys.Find(id);

                    if (rec != null)
                    {
                        ent.SchedulingDiarys.Remove(rec);
                        ent.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }