public ActionResult AddUsers(string stylistname, string email) { TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["name"].ConnectionString; using (MySqlConnection conn = new MySqlConnection(connstr)) { try { using (MySqlCommand cmd = new MySqlCommand("spAddUser", conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; // cmd.Parameters.Add(new MySqlParameter("stylist", MySqlDbType.Int32, myStylistid)); MySqlParameter[] pms = new MySqlParameter[2]; pms[0] = new MySqlParameter("name", MySqlDbType.VarChar, 40); pms[0].Value = stylistname; pms[1] = new MySqlParameter("email", MySqlDbType.VarChar, 40); pms[1].Value = email; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spAddUser"; cmd.Parameters.AddRange(pms); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } catch (Exception ex) { var str = ex.Message; } } return(Json("[]", JsonRequestBehavior.AllowGet)); }
public ActionResult AddAppointment(string name, string phone, string style, string info, string stylist, string date, string time) { TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); int myStylistid = 1; var st = context.stylists.Where(s => s.name == stylist).FirstOrDefault(); if (st != null) { myStylistid = (int)st.id; } int iTime = int.Parse(time); string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["name"].ConnectionString; List <UserDetails> userlist = new List <UserDetails>(); using (MySqlConnection conn = new MySqlConnection(connstr)) { try { using (MySqlCommand cmd = new MySqlCommand("spUpdateAvailabilty", conn)) { MySqlParameter[] pms = new MySqlParameter[8]; pms[0] = new MySqlParameter("name", MySqlDbType.VarChar, 40); pms[0].Value = name; pms[1] = new MySqlParameter("phone", MySqlDbType.VarChar, 40); pms[1].Value = phone; pms[2] = new MySqlParameter("style", MySqlDbType.VarChar, 40); pms[2].Value = style; pms[3] = new MySqlParameter("info", MySqlDbType.VarChar, 40); pms[3].Value = info; pms[4] = new MySqlParameter("stylist", MySqlDbType.VarChar, 40); pms[4].Value = stylist; pms[5] = new MySqlParameter("date", MySqlDbType.VarChar, 10); pms[5].Value = date; pms[6] = new MySqlParameter("time", MySqlDbType.Int32); pms[6].Value = iTime; pms[7] = new MySqlParameter("sid", MySqlDbType.Int32); pms[7].Value = myStylistid; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spAddAppointment"; cmd.Parameters.AddRange(pms); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } catch (Exception ex) { var str = ex.Message; } } return(Json("[]", JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); List <stylist> stylists = context.stylists.ToList(); // string myText = "<select id=\"postage\"><option value=\"0\">Please select...</option><option value=\"1\">Anyone Available</option> "; string myText = "<select id=\"postage\"><option value=\"0\">Please select...</option> "; foreach (stylist dresser in stylists) { myText = myText + "<option value=\"" + dresser.id + "\">" + dresser.name + "</option>"; } myText = myText + " </select>"; ViewBag.dropdowntext = myText; myText = "<select id=\"postage\"><option value=\"0\">Please select...</option><option value=\"1\">New User</option> "; foreach (stylist dresser in stylists) { myText = myText + "<option value=\"" + dresser.id + "\">" + dresser.name + "</option>"; } myText = myText + " </select>"; ViewBag.userdropdown = myText; return(View()); }
public ActionResult GetAllAppointments() { List <aAppointment> userlist = new List <aAppointment>(); TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["name"].ConnectionString; using (MySqlConnection conn = new MySqlConnection(connstr)) { MySqlDataReader rdr = null; try { using (MySqlCommand cmd = new MySqlCommand("spAllAppointments", conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; // cmd.Parameters.Add(new MySqlParameter("stylist", MySqlDbType.Int32, myStylistid)); // MySqlParameter[] pms = new MySqlParameter[1]; // pms[0] = new MySqlParameter("stylistid", MySqlDbType.VarChar, 40); // pms[0].Value = myStylistid; // pms[1] = new MySqlParameter("email", MySqlDbType.VarChar, 40); // pms[1].Value = email; // cmd.Parameters.AddRange(pms); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spAllAppointments"; // cmd.Parameters.AddRange(pms); conn.Open(); rdr = cmd.ExecuteReader(); var jsonResult = new System.Text.StringBuilder(); if (!rdr.HasRows) { jsonResult.Append("[]"); } else { while (rdr.Read()) { aAppointment userslot = new aAppointment(); userslot.dayoftheweek = rdr.GetValue(2).ToString(); userslot.theday = rdr.GetValue(11).ToString(); userslot.stylistid = rdr.GetValue(1).ToString(); userslot.dayId = rdr.GetValue(2).ToString(); userslot.starttime = rdr.GetValue(3).ToString(); userslot.name = rdr.GetValue(6).ToString(); userslot.phone = rdr.GetValue(7).ToString(); userslot.style = rdr.GetValue(8).ToString(); userslot.info = rdr.GetValue(9).ToString(); userslot.stylist = rdr.GetValue(10).ToString(); userslot.appdate = rdr.GetValue(11).ToString(); userslot.apptime = rdr.GetValue(5).ToString(); userlist.Add(userslot); } } conn.Close(); } } catch (Exception ex) { var str = ex.Message; } } return(Json(userlist, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateUser(string stylist, string arrayhrs, string day) { TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); int myStylistid = 1; var st = context.stylists.Where(s => s.name == stylist).FirstOrDefault(); if (st != null) { myStylistid = (int)st.id; } dynamic table = JsonConvert.DeserializeObject(arrayhrs); string hrs = ""; int i = 0; foreach (var item in table.hrs) { i++; if (item == true) { hrs = hrs + i.ToString() + ","; } } int dayId = 1; if (day == "Sunday") { dayId = 1; } else if (day == "Monday") { dayId = 2; } else if (day == "Tuesday") { dayId = 3; } else if (day == "Wednesday") { dayId = 4; } else if (day == "Thursday") { dayId = 5; } else if (day == "Friday") { dayId = 6; } else if (day == "Saturday") { dayId = 7; } // List<string> data = arrayhrs.Split(',').ToList(); // foreach (Boolean yes in arrayhrs) // { // // // } string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["name"].ConnectionString; MySqlDataReader rdr = null; List <UserDetails> userlist = new List <UserDetails>(); using (MySqlConnection conn = new MySqlConnection(connstr)) { try { if (hrs.Length > 0) { hrs = hrs.Remove(hrs.Length - 1, 1); } using (MySqlCommand cmd = new MySqlCommand("spUpdateAvailabilty", conn)) { MySqlParameter[] pms = new MySqlParameter[3]; pms[0] = new MySqlParameter("stylist", MySqlDbType.Int32); pms[0].Value = myStylistid; pms[1] = new MySqlParameter("hrs", MySqlDbType.VarChar, 100); pms[1].Value = hrs; pms[2] = new MySqlParameter("xayId", MySqlDbType.Int32); pms[2].Value = dayId; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spUpdateAvailabilty"; cmd.Parameters.AddRange(pms); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } catch (Exception ex) { var str = ex.Message; } } // context.spUpdateAvailabilty(stylist, hrs, dayId); List <stylist> stylists = context.stylists.ToList(); return(Json(stylists, JsonRequestBehavior.AllowGet)); }
public ActionResult GetUsers(string stylist) { TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); int myStylistid = 1; var st = context.stylists.Where(s => s.name == stylist).FirstOrDefault(); if (st != null) { myStylistid = (int)st.id; } string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["name"].ConnectionString; MySqlDataReader rdr = null; List <UserDetails> userlist = new List <UserDetails>(); using (MySqlConnection conn = new MySqlConnection(connstr)) { try { using (MySqlCommand cmd = new MySqlCommand("spGetUserDetails", conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; conn.Open(); // cmd.Parameters.Add(new MySqlParameter("stylist", MySqlDbType.Int32, myStylistid)); MySqlParameter[] pms = new MySqlParameter[1]; pms[0] = new MySqlParameter("mykey", MySqlDbType.Int32); pms[0].Value = myStylistid; cmd.Parameters.AddRange(pms); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spGetUserDetails"; rdr = cmd.ExecuteReader(); var jsonResult = new System.Text.StringBuilder(); if (!rdr.HasRows) { jsonResult.Append("[]"); } else { while (rdr.Read()) { UserDetails userslot = new UserDetails(); //userslot.name = rdr.GetValue(0).ToString(); //userslot.email = rdr.GetValue(1).ToString(); //userslot.id = rdr.GetValue(2).ToString(); userslot.stylistId = rdr.GetValue(1).ToString(); userslot.dayId = rdr.GetValue(0).ToString(); userslot.starttime = rdr.GetValue(2).ToString(); userslot.time = rdr.GetValue(3).ToString(); userlist.Add(userslot); } } conn.Close(); } } catch (Exception ex) { var str = ex.Message; } } return(Json(userlist, JsonRequestBehavior.AllowGet)); }
public ActionResult Appointment(string stylist) { List <bookingview> daycal = new List <bookingview>(); if (stylist == null) { return(RedirectToAction("Index")); } ViewBag.Stylist = stylist; Bookings myBookings = new Bookings(); List <Booking> thebook = myBookings.GetBookings(); List <string> myDates = new List <string>(); List <string> myDays = new List <string>(); // myDates.Add(DateTime.Today.ToShortDateString()); int i = 0; while (i <= 6) { int j = 9; TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); List <availability> slots = context.availabilities.Where(s => s.stylistId.ToString() == stylist && s.dayId == 1).ToList(); foreach (availability slot in slots) { bookingview calEntry = new bookingview(); calEntry.date = DateTime.Today.AddDays(i).ToShortDateString(); if (i == 0) { calEntry.datedetail = "Today"; } else { calEntry.datedetail = DateTime.Today.AddDays(i).DayOfWeek.ToString(); } var timeStr = slot.time.ToString() + ":00"; if (j < 10) { timeStr = "0" + timeStr; } calEntry.time = timeStr; calEntry.stylist = stylist; calEntry.customer = ""; var result = thebook.Find(x => x.date == DateTime.Today.AddDays(i).ToShortDateString() && x.time == timeStr && x.stylist == stylist); if (result != null) { calEntry.customer = result.name; calEntry.phone = result.phone; calEntry.style = result.style == null ? "n/a" : result.style; calEntry.info = result.info == null ? "n/a" : result.info; } daycal.Add(calEntry); j++; } myDates.Add(DateTime.Today.AddDays(i).ToShortDateString()); i++; } ViewBag.BookingDates = myDates; myDays.Add("Today"); i = 1; while (i <= 6) { myDays.Add(DateTime.Today.AddDays(i).DayOfWeek.ToString()); i++; } ViewBag.BookingDays = myDays; return(View("Appointment")); }