Example #1
0
        public static List<DiaryEvent> LoadAppointmentSummaryInDateRange(double start, double end)
        {

            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate = ConvertFromUnixTimestamp(end);
            using (DiaryContainer ent = new DiaryContainer())
            {
                var rslt = ent.AppointmentDiary.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate)
                                                        .GroupBy(s => EntityFunctions.TruncateTime(s.DateTimeScheduled))
                                                        .Select(x => new { DateTimeScheduled = x.Key, Count = x.Count() });

                List<DiaryEvent> result = new List<DiaryEvent>();
                int i = 0;
                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();
                    rec.ID = i; //we dont link this back to anything as its a group summary but the fullcalendar needs unique IDs for each event item (unless its a repeating event)
                    rec.SomeImportantKeyID = -1;
                    string StringDate = string.Format("{0:yyyy-MM-dd}", item.DateTimeScheduled);
                    rec.StartDateString = StringDate + "T00:00:00"; //ISO 8601 format
                    rec.EndDateString = StringDate + "T23:59:59";
                    rec.Title = "Booked: " + item.Count.ToString();
                    result.Add(rec);
                    i++;
                }

                return result;
            }

        }
Example #2
0
        public static List<DiaryEvent> LoadAllAppointmentsInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate = ConvertFromUnixTimestamp(end);
            using (DiaryContainer ent = new DiaryContainer())
            {
                var rslt = ent.AppointmentDiary.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate);

                List<DiaryEvent> result = new List<DiaryEvent>();
                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();
                    rec.ID = item.ID;
                    rec.SomeImportantKeyID = item.SomeImportantKey;
                    rec.StartDateString = item.DateTimeScheduled.ToString("s"); // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                    rec.EndDateString = item.DateTimeScheduled.AddMinutes(item.AppointmentLength).ToString("s"); // field AppointmentLength is in minutes
                    rec.Title = item.Title + " - " + item.AppointmentLength.ToString() + " mins";
                    rec.StatusString = Enums.GetName<AppointmentStatus>((AppointmentStatus)item.StatusENUM);
                    rec.StatusColor = Enums.GetEnumDescription<AppointmentStatus>(rec.StatusString);
                    string ColorCode = rec.StatusColor.Substring(0, rec.StatusColor.IndexOf(":"));
                    rec.ClassName = rec.StatusColor.Substring(rec.StatusColor.IndexOf(":") + 1, rec.StatusColor.Length - ColorCode.Length - 1);
                    rec.StatusColor = ColorCode;
                    result.Add(rec);
                }

                return result;
            }

        }
Example #3
0
 public static bool CreateNewEvent(string Title, string Description, string NewEventDate, string NewEventTime, string NewEventDuration, EventType eventType, int EventID = 0)
 {
     try
     {
         DiaryContainer   ent = new DiaryContainer();
         AppointmentDiary rec = new AppointmentDiary();
         rec.Title             = Title; rec.Description = Description; rec.EventType = (int)eventType;
         rec.DateTimeScheduled = DateTime.ParseExact(NewEventDate + " " + NewEventTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
         rec.AppointmentLength = Int32.Parse(NewEventDuration);
         if (EventID > 0)
         {
             rec.ID = EventID;
             ent.Entry(rec).State = System.Data.Entity.EntityState.Modified;
             ent.SaveChanges();
         }
         else
         {
             ent.AppointmentDiary.Add(rec);
             ent.SaveChanges();
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
        public static List <DiaryEvent> LoadAllAppointmentsInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            using (DiaryContainer ent = new DiaryContainer())
            {
                var rslt = ent.AppointmentDiary.Where(s => s.DateTimeScheduled >= fromDate && System.Data.Objects.EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate);

                List <DiaryEvent> result = new List <DiaryEvent>();
                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();
                    rec.ID = item.ID;
                    rec.SomeImportantKeyID = item.SomeImportantKey;
                    rec.StartDateString    = item.DateTimeScheduled.ToString("s");                                    // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                    rec.EndDateString      = item.DateTimeScheduled.AddMinutes(item.AppointmentLength).ToString("s"); // field AppointmentLength is in minutes
                    rec.Title        = item.Title + " - " + item.AppointmentLength.ToString() + " mins";
                    rec.StatusString = Enums.GetName <AppointmentStatus>((AppointmentStatus)item.StatusENUM);
                    rec.StatusColor  = Enums.GetEnumDescription <AppointmentStatus>(rec.StatusString);
                    string ColorCode = rec.StatusColor.Substring(0, rec.StatusColor.IndexOf(":"));
                    rec.ClassName   = rec.StatusColor.Substring(rec.StatusColor.IndexOf(":") + 1, rec.StatusColor.Length - ColorCode.Length - 1);
                    rec.StatusColor = ColorCode;
                    result.Add(rec);
                }

                return(result);
            }
        }
        public static List <DiaryEvent> LoadAppointmentSummaryInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            using (DiaryContainer ent = new DiaryContainer())
            {
                var rslt = ent.AppointmentDiary.Where(s => s.DateTimeScheduled >= fromDate && System.Data.Objects.EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate)
                           .GroupBy(s => System.Data.Objects.EntityFunctions.TruncateTime(s.DateTimeScheduled))
                           .Select(x => new { DateTimeScheduled = x.Key, Count = x.Count() });

                List <DiaryEvent> result = new List <DiaryEvent>();
                int i = 0;
                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();
                    rec.ID = i; //we dont link this back to anything as its a group summary but the fullcalendar needs unique IDs for each event item (unless its a repeating event)
                    rec.SomeImportantKeyID = -1;
                    string StringDate = string.Format("{0:yyyy-MM-dd}", item.DateTimeScheduled);
                    rec.StartDateString = StringDate + "T00:00:00"; //ISO 8601 format
                    rec.EndDateString   = StringDate + "T23:59:59";
                    rec.Title           = "Booked: " + item.Count.ToString();
                    result.Add(rec);
                    i++;
                }

                return(result);
            }
        }
Example #6
0
        public static bool InitialiseDiary()
        {
            // init connection to database
            DiaryContainer ent = new DiaryContainer();
            try
            {
                for (int i = 0; i < 30; i++)
                {
                    AppointmentDiary item = new AppointmentDiary();
                    // record ID is auto generated
                    item.Title = "Appt: " + i.ToString();
                    item.SomeImportantKey = i;
                    item.StatusENUM = GetRandomValue(0, 3); // random is exclusive - we have three status enums
                    if (i <= 5) // create a few appointments for todays date
                    {
                        item.DateTimeScheduled = GetRandomAppointmentTime(false, true);
                    }
                    else
                    {  // rest of appointments on previous and future dates
                        if (i % 2 == 0)
                            item.DateTimeScheduled = GetRandomAppointmentTime(true, false); // flip/flop between date ahead of today and behind today
                        else item.DateTimeScheduled = GetRandomAppointmentTime(false, false);
                    }
                    item.AppointmentLength = GetRandomValue(1, 5) * 15; // appoiment length in blocks of fifteen minutes in this demo
                    ent.AppointmentDiary.Add(item);
                    ent.SaveChanges();
                }
            }
            catch (Exception)
            {
                return false;
            }

            return ent.AppointmentDiary.Count() > 0;
        }
Example #7
0
        public ActionResult Expand()
        {
            DiaryContainer db = new DiaryContainer();

            var donation = db.Donation.FirstOrDefault();

            ViewBag.TargetAmount = String.Format("{0:n0}", donation.TargetAmount);
            ViewBag.CurrAmount   = String.Format("{0:n0}", donation.CurrentAmount);

            return(View());
        }
Example #8
0
        public JsonResult SendContact(ContactInfo model)
        {
            //   bool isOK = false;

            var contact = new ContactInfo {
                FullName = model.FullName, Email = model.Email, Phone = model.Phone, Message = model.Message, DateSent = DateTime.Now
            };
            DiaryContainer db = new DiaryContainer();

            db.ContactInfo.Add(contact);
            db.SaveChanges();
            return(Json("Your message has been sent successfully. We will contact you with feedback shortly.", JsonRequestBehavior.DenyGet));
        }
Example #9
0
        public static bool InitialiseDiary()
        {
            DiaryContainer ent = new DiaryContainer();

            try
            {
                for (int i = 0; i < 30; i++)
                {
                    AppointmentDiary item = new AppointmentDiary();

                    //record ID is auto generated
                    item.Title            = "Appt : " + i.ToString();
                    item.SomeImportantKey = i;
                    item.StatuENUM        = GetRandomValue(0, 3); //radom is exclusive - we have three status enums

                    if (i <= 5)                                   //create ten appointments for todays date
                    {
                        item.DateTimeSchedule = GetRandomAppointmentTime(false, true);
                    }
                    else
                    {
                        //rest of appointments on previous and future dates

                        if (i % 2 == 0)
                        {
                            item.DateTimeSchedule = GetRandomAppointmentTime(true, false);

                            //flip/flop between date ahead of today and behind today
                        }
                        else
                        {
                            item.DateTimeSchedule = GetRandomAppointmentTime(false, false);
                        }

                        item.AppointmentLength = GetRandomValue(1, 5) * 15;

                        //appointment length always less than an hour in blocks of fifteen

                        ent.AppointmentDiaries.Add(item);
                        ent.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(ent.AppointmentDiaries.Count() > 0);
        }
Example #10
0
        public FileContentResult GetGalleryImage(int imageID)
        {
            DiaryContainer db  = new DiaryContainer();
            ArtWorks       art = db.ArtWorks.FirstOrDefault(p => p.ArtWorkID == imageID);

            if (art != null)
            {
                return(File(art.ImageData, art.ImageMimeType.ToString()));
            }
            else
            {
                return(null);
            }
        }
Example #11
0
        public ActionResult Index()
        {
            var            timeUtc     = DateTime.UtcNow;
            TimeZoneInfo   easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            DateTime       easternTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, easternZone);
            DiaryContainer db          = new DiaryContainer();

            var donation = db.Donation.FirstOrDefault();

            ViewBag.CurrDate     = easternTime.ToLongDateString();
            ViewBag.TargetAmount = String.Format("{0:n0}", donation.TargetAmount);
            ViewBag.CurrAmount   = String.Format("{0:n0}", donation.CurrentAmount);
            return(View());
        }
Example #12
0
 public static bool CreateNewEvent(string Title, string NewEventDate, string NewEventTime, string NewEventDuration)
 {
     try
     {
         DiaryContainer   ent = new DiaryContainer();
         AppointmentDiary rec = new AppointmentDiary();
         rec.Title             = Title;
         rec.DateTimeScheduled = DateTime.ParseExact(NewEventDate + " " + NewEventTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
         rec.AppointmentLength = Int32.Parse(NewEventDuration);
         ent.AppointmentDiary.Add(rec);
         ent.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Example #13
0
 public static void UpdateDiaryEvent(int id, string NewEventStart, string NewEventEnd)
 {
     // EventStart comes ISO 8601 format, eg:  "2000-01-10T10:00:00Z" - need to convert to DateTime
     using (DiaryContainer ent = new DiaryContainer()) {
         var rec = ent.AppointmentDiary.FirstOrDefault(s => s.ID == id);
         if (rec != null)
         {
             DateTime DateTimeStart = DateTime.Parse(NewEventStart, null, DateTimeStyles.RoundtripKind).ToLocalTime(); // and convert offset to localtime
             rec.DateTimeScheduled = DateTimeStart;
             if (!String.IsNullOrEmpty(NewEventEnd))
             {
                 TimeSpan span = DateTime.Parse(NewEventEnd, null, DateTimeStyles.RoundtripKind).ToLocalTime() - DateTimeStart;
                 rec.AppointmentLength = Convert.ToInt32(span.TotalMinutes);
             }
             ent.SaveChanges();
         }
     }
 }
Example #14
0
        public JsonResult GetEvents()
        {
            DiaryContainer db = new DiaryContainer();
            IEnumerable <AppointmentDiary> list = (from t in db.AppointmentDiary

                                                   orderby t.DateTimeScheduled descending
                                                   select t).Take(3);
            var eventList = from e in list
                            select new Models.GalleryEvent
            {
                GalleryEventID = e.ID,
                Title          = e.Title,
                EventDate      = e.DateTimeScheduled.ToString("MM/dd/yyyy hh:mm:ss tt"),
                Description    = e.Description,
                EventType      = e.EventType,
            };

            return(Json(eventList.ToList(), JsonRequestBehavior.AllowGet));
        }
Example #15
0
        //public ActionResult RenderPDF(int id)
        //{
        //    ViewData["fileID"] = id;

        //    return PartialView("_PDFPartial");
        //}

        public FileResult DownloadFile(int fileID)
        {
            DiaryContainer db   = new DiaryContainer();
            var            file = db.Folder.Find(fileID);

            if (file != null)
            {
                string fileName = file.FileName;
                string filePath = "/Allfiles/";

                if (System.Configuration.ConfigurationManager.AppSettings["TempFilePath"] != null)
                {
                    filePath = System.Configuration.ConfigurationManager.AppSettings["TempFilePath"] + filePath;
                }

                byte[] fileBytes = System.IO.File.ReadAllBytes(filePath + fileName);
                return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
            }
            else
            {
                return(null);
            }
        }
Example #16
0
        public FileResult ViewPDFFile(int fileID)
        {
            DiaryContainer db   = new DiaryContainer();
            var            file = db.Folder.Find(fileID);

            if (file != null)
            {
                string fileName = file.FileName;
                string filePath = "/Allfiles/";

                filePath = System.Configuration.ConfigurationManager.AppSettings["TempFilePath"] + filePath;
                //if (System.Configuration.ConfigurationManager.AppSettings["TempFilePath"] != null)
                // {
                // }

                byte[] fileBytes = System.IO.File.ReadAllBytes(filePath + fileName);
                return(File(fileBytes, "application/pdf"));
            }
            else
            {
                return(null);
            }
        }
Example #17
0
        public JsonResult GetGallery()
        {
            DiaryContainer db = new DiaryContainer();

            var list = (from t in db.ArtWorks
                        orderby t.DateAdded descending
                        select t).Take(8);

            List <Models.ImageItem> eventList = new List <Models.ImageItem>();

            foreach (var item in list)
            {
                eventList.Add(
                    new Models.ImageItem
                {
                    Description = Utilities.StringExtensions.CutString(ImageEvent(db, item.ID).Description, 80),
                    ImageID     = item.ArtWorkID,
                    Title       = Utilities.StringExtensions.CutString(ImageEvent(db, item.ID).Title, 15)
                });
            }

            return(Json(eventList, JsonRequestBehavior.AllowGet));
        }
Example #18
0
 public AppointmentDiary ImageEvent(DiaryContainer db, int?ID)
 {
     return(db.AppointmentDiary.Find(ID));
 }
Example #19
0
        public static void UpdateDiaryEvent(int id, string NewEventStart, string NewEventEnd)
        {
            // EventStart comes ISO 8601 format, eg:  "2000-01-10T10:00:00Z" - need to convert to DateTime
            using (DiaryContainer ent = new DiaryContainer())
            {
                var rec = ent.AppointmentDiary.FirstOrDefault(s => s.ID == id);
                if (rec != null)
                {
                    DateTime DateTimeStart = DateTime.Parse(NewEventStart, null, DateTimeStyles.RoundtripKind).ToLocalTime(); // and convert offset to localtime
                    rec.DateTimeScheduled = DateTimeStart;
                    if (!String.IsNullOrEmpty(NewEventEnd))
                    {
                        TimeSpan span = DateTime.Parse(NewEventEnd, null, DateTimeStyles.RoundtripKind).ToLocalTime() - DateTimeStart;
                        rec.AppointmentLength = Convert.ToInt32(span.TotalMinutes);
                    }
                    ent.SaveChanges();
                }
            }

        }
Example #20
0
 public static bool CreateNewEvent(string Title, string NewEventDate, string NewEventTime, string NewEventDuration)
 {
     try
     {
         DiaryContainer ent = new DiaryContainer();
         AppointmentDiary rec = new AppointmentDiary();
         rec.Title = Title;
         rec.DateTimeScheduled = DateTime.ParseExact(NewEventDate + " " + NewEventTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
         rec.AppointmentLength = Int32.Parse(NewEventDuration);
         ent.AppointmentDiary.Add(rec);
         ent.SaveChanges();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }