public static List <AppointmentDiary> LoadAllAppointmentsInDateRange(double start, double end) { var fromDate = ConvertFromUnixTimestamp(start); var toDate = ConvertFromUnixTimestamp(end); //using (LocationDBEntities1 ent = new LocationDBEntities1()) //{ // var rslt = ent.AppointmentDiaries.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate); // List<AMPEvents> result = new List<AMPEvents >(); // foreach (var item in rslt) // { // AMPEvents rec = new AMPEvents(); // 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; //} AppointmentDiary objAppointment = new AppointmentDiary(); DataAccessLayer objDB = new DataAccessLayer(); //calling class DBdata objAppointment.ShowallAppointment = objDB.SelectallAvailabilitydata(null); return(objAppointment.ShowallAppointment); }
public ActionResult Edit([Bind(Include = "SomeImportantKey,Title,StatusENUM,DateTimeScheduled,AppointmentLength,ID")] AppointmentDiary appointmentDiary, string Hours) { appointmentDiary.UserId = UserId = User.Identity.Name; var dt = string.Concat(appointmentDiary.DateTimeScheduled.ToShortDateString(), " ", Hours); var dateTime = DateTime.ParseExact( dt, "dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture ); appointmentDiary.DateTimeScheduled = dateTime; if (ModelState.IsValid) { //_appointmentDiaryService.u return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(_appointmentDiaryService.RetrieveAppointmentDiaries(UserId), "ID", "Title", appointmentDiary.ID); ViewBag.Hours = new SelectList(Enumerable.Range(00, 24).Select(i => (DateTime.MinValue.AddHours(i)).ToString("hh:mm tt")), "Hours"); return(View(appointmentDiary)); }
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 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; }
public ActionResult DeleteConfirmed(int id) { AppointmentDiary appointmentdiary = db.AppointmentDiary.Find(id); db.AppointmentDiary.Remove(appointmentdiary); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { UserId = User.Identity.Name; AppointmentDiary appointmentDiary = _appointmentDiaryService.RetrieveAppointmentDiary(id, UserId); _appointmentDiaryService.RemoveAppointmentDiary(appointmentDiary); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { AppointmentDiary appointmentdiary = db.AppointmentDiary.Find(id); if (appointmentdiary == null) { return(HttpNotFound()); } return(View(appointmentdiary)); }
public ActionResult Edit(AppointmentDiary appointmentdiary) { if (ModelState.IsValid) { db.Entry(appointmentdiary).State = EntityState.Modified;// System.Data.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(appointmentdiary)); }
public void UpdateAppointmentDiary(AppointmentDiary appointmentDiary) { try { _appointmentDiaryRepository.UpdateAppointmentDiary(appointmentDiary); } catch (Exception ex) { throw ex; } }
public void AddAppointmentDiary(AppointmentDiary appointmentDiary) { try { _appointmentDiaryRepository.InsertAppointmentDiary(appointmentDiary); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> Edit([Bind(Include = "ID,Title,SomeImportantKey,DateTimeScheduled,AppointmentLength,StatusENUM")] AppointmentDiary appointmentDiary) { if (ModelState.IsValid) { Db.Entry(appointmentDiary).State = EntityState.Modified; await Db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(appointmentDiary)); }
public void RemoveAppointmentDiary(AppointmentDiary appointmentDiary) { try { _appointmentDiaryRepository.DeleteAppointmentDiary(appointmentDiary); } catch (Exception ex) { throw ex; } }
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); }
public static bool CreateNewEvent(string Title, string NewEventDate, string NewEventTime, string NewEventDuration) { try { FullCalendarMVC_DemoEntities ent = new FullCalendarMVC_DemoEntities(); 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.AppointmentDiaries.Add(rec); ent.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public List <AppointmentDiary> SelectallAvailabilitydata(string userId) { SqlConnection con = null; DataSet ds = null; List <AppointmentDiary> aptlist = null; try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString()); SqlCommand cmd = new SqlCommand("sp_IUD_Availability", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", userId); cmd.Parameters.AddWithValue("@Query", 4); con.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; ds = new DataSet(); da.Fill(ds); aptlist = new List <AppointmentDiary>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string StringDate = string.Format("{0:yyyy-MM-dd}", ds.Tables[0].Rows[i]["DateTimeScheduled"]); AppointmentDiary aobj = new AppointmentDiary(); aobj.id = Convert.ToInt32(ds.Tables[0].Rows[i]["ID"].ToString()); aobj.someKey = Convert.ToInt16(ds.Tables[0].Rows[i]["SomeImportantKey"]); aobj.allDay = Convert.ToInt16(ds.Tables[0].Rows[i]["StatusENUM"]); aobj.title = Convert.ToString(ds.Tables[0].Rows[i]["Title"]); aobj.start = StringDate + "T00:00:00"; aobj.end = StringDate + "T23:59:59"; aptlist.Add(aobj); } return(aptlist); } catch { return(aptlist); } finally { con.Close(); } }
public JsonResult GetDiaryEvents(double start, double end) { //var ApptListForDate = AMPEvents.LoadAllAppointmentsInDateRange(start, end); //var eventList = from e in ApptListForDate // select new // { // id = e.ID, // title = e.Title, // start = e.StartDateString, // end = e.EndDateString, // color = e.StatusColor, // className = e.ClassName, // someKey = e.SomeImportantKeyID, // allDay = false // }; //var rows = eventList.ToArray(); //string jsonData = new JavaScriptSerializer().Serialize(Json(rows, JsonRequestBehavior.AllowGet)); //string json = new JavaScriptSerializer().Serialize(rows); string userIdValue = string.Empty; var claimsIdentity = User.Identity as ClaimsIdentity; if (claimsIdentity != null) { // the principal identity is a claims identity. // now we need to find the NameIdentifier claim var userIdClaim = claimsIdentity.Claims .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier); if (userIdClaim != null) { userIdValue = userIdClaim.Value; } } AppointmentDiary objAppointment = new AppointmentDiary(); DataAccessLayer objDB = new DataAccessLayer(); //calling class DBdata objAppointment.ShowallAppointment = objDB.SelectallAvailabilitydata(userIdValue); return(Json(objAppointment, JsonRequestBehavior.AllowGet)); }
public IEnumerable <AppointmentDiary> GetAppointmentDiaries() { List <AppointmentDiary> appointmentDiaries = new List <AppointmentDiary>(); for (int i = 0; i < 30; i++) { AppointmentDiary item = new AppointmentDiary { ID = i, Title = "Appt: " + i.ToString(), SomeImportantKey = i, StatusENUM = rnd.Next(0, 3) // random is exclusive - we have three status enums }; item.DateTimeScheduled = i <= 5 ? GetRandomAppointmentTime(false, true) : item.DateTimeScheduled = GetRandomAppointmentTime(i % 2 == 0, false); item.AppointmentLength = rnd.Next(1, 5) * 15; // appoiment length in blocks of fifteen minutes in this demo appointmentDiaries.Add(item); } return(appointmentDiaries); }
public static bool CreateNewEvent(string Title, string NewEventDate) { try { I4IDBEntities ent = new I4IDBEntities(); AppointmentDiary rec = new AppointmentDiary(); string userNoCookiesVale = HttpContext.Current.Request.Cookies["UserNo"].Value; var result =(from r in ent.RegisterUsers where r.UserNo==userNoCookiesVale && r.UserRole=="T" select new { r.Id }); rec.id = Convert.ToInt32(result.FirstOrDefault().Id); rec.Title = Title; DateTime dt = DateTime.ParseExact(NewEventDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); rec.DateTimeScheduled = dt; //rec.AppointmentLength = Int32.Parse(NewEventDuration); ent.AppointmentDiaries.Add(rec); ent.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; return false; } return true; }
public static bool CreateNewEvent(string Title, string NewEventDate) { try { I4IDBEntities ent = new I4IDBEntities(); AppointmentDiary rec = new AppointmentDiary(); string userNoCookiesVale = HttpContext.Current.Request.Cookies["UserNo"].Value; var result = (from r in ent.RegisterUsers where r.UserNo == userNoCookiesVale && r.UserRole == "T" select new { r.Id }); rec.id = Convert.ToInt32(result.FirstOrDefault().Id); rec.Title = Title; DateTime dt = DateTime.ParseExact(NewEventDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); rec.DateTimeScheduled = dt; //rec.AppointmentLength = Int32.Parse(NewEventDuration); ent.AppointmentDiaries.Add(rec); ent.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; return(false); } return(true); }
public static bool InitialiseDiary() { // init connection to database FullCalendarMVC_DemoEntities ent = new FullCalendarMVC_DemoEntities(); 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.AppointmentDiaries.Add(item); ent.SaveChanges(); } } catch (Exception) { return(false); } return(ent.AppointmentDiaries.Count() > 0); }
public void Delete(AppointmentDiary itemToDelete) { _context.AppointmentDiary.Remove(itemToDelete); }
public AppointmentDiary Update(AppointmentDiary itemToUpdate) { _context.Entry(itemToUpdate).State = EntityState.Modified; return(itemToUpdate); }
public AppointmentDiary Create(AppointmentDiary itemToCreate) { var diaryEvent = _context.AppointmentDiary.Add(itemToCreate); return(diaryEvent); }
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; }