//private static string getController() //{ // try // { // return HttpContext.Current.Request.FilePath.Substring(1, HttpContext.Current.Request.FilePath.LastIndexOf("/") - 1); // } // catch (Exception ex) // { // return "getControllerErrored"; // } //} //private static string getPage() //{ // try // { // return HttpContext.Current.Request.FilePath.Substring(HttpContext.Current.Request.FilePath.LastIndexOf("/") + 1); // } // catch (Exception ex) // { // return "getPageErrored"; // } //} public static int CreateFavorite(PatientLogModel db, string users, string hospitals, string types, string name, bool isDefault) { ScheduleFavorite fave = new ScheduleFavorite(); fave.Users = users; fave.Hospital = hospitals; fave.Types = types; fave.Name = name; fave.Default = isDefault; fave.UserID = HubSecurity.getLoggedInUserID(); //If this entry is set to be default, make sure all current ones get default put to false if (isDefault) { List <int> ids = (from f in db.ScheduleFavorites where f.UserID == fave.UserID select f.ID).ToList(); foreach (int id in ids) { ScheduleFavorite f = db.ScheduleFavorites.Find(id); f.Default = false; db.Entry(f).State = EntityState.Modified; } } db.ScheduleFavorites.Add(fave); db.SaveChanges(); return(fave.ID); }
public static ScheduleFavorite getFavorite(PatientLogModel db, string id) { int newID = Convert.ToInt32(id); ScheduleFavorite ret = (from f in db.ScheduleFavorites where f.ID == newID select f).Single(); return(ret); }
public static string DeleteFavorite(PatientLogModel db, string id) { int newID = Convert.ToInt32(id); string name; ScheduleFavorite f = db.ScheduleFavorites.Find(newID); name = f.Name; db.ScheduleFavorites.Remove(f); db.SaveChanges(); return(name); }
//public static void SetDailyRepeatSchedule(PatientLogModel db, string user, string hospital, string type, DateTime start, DateTime end, int interval, DateTime repeatTo) //{ //} public static string SetDefaultFavorite(PatientLogModel db, string id) { string userid = HubSecurity.getLoggedInUserID(); string ret; int newID = Convert.ToInt32(id); List <ScheduleFavorite> query = (from f in db.ScheduleFavorites where f.UserID == userid select f).ToList(); foreach (ScheduleFavorite f in query) { f.Default = false; db.Entry(f).State = EntityState.Modified; } ScheduleFavorite newD = db.ScheduleFavorites.Find(newID); ret = newD.Name; newD.Default = true; db.Entry(newD).State = EntityState.Modified; db.SaveChanges(); return(ret); }