static TextRepository() { string path = Path.Combine(HttpRuntime.AppDomainAppPath, _csvFilename); _texts = new List<MessageViewModel>(); int id = 1; foreach (var line in File.ReadAllLines(path)) { var lineSegments = line.Split(','); var text = lineSegments[0]; var texts = new MessageViewModel { Id = id++, Text = text }; _texts.Add(texts); } }
public ActionResult MessageToCustomer(int? id) { Request request = db.Requests.Find(id); /* Here we get the customer or wishers SessionID and store it in the model. */ Session["_UserSession"] = System.Web.HttpContext.Current.Session.SessionID; string userSession = Session["_UserSession"] as string; var model = new MessageViewModel { Request = request, SessionID = userSession, IDRequest = id, Avsändare = request.Avsändare }; /* All the values that the models requires are stored in TempData["MessageToCustomer"] so we can use it in the neaxt ActionResult Message. */ TempData["MessageToCustomer"] = model; return View(model); }
public ActionResult Message(string message, string sessionid) { MessageViewModel requestdata = TempData["MessageToCustomer"] as MessageViewModel; if (!string.IsNullOrEmpty(sessionid) && requestdata != null) { int? id = requestdata.IDRequest; Request request = db.Requests.Find(id); bool noPlayBoolProp = false; var hasSuccess = (TempData["NotPlay"] != null) == true; if (hasSuccess) { string boolValue = TempData["NotPlay"].ToString(); if (boolValue == "true") { noPlayBoolProp = true; } noPlayBoolProp = true; } var model = new MessageViewModel { Message = message, SessionID = sessionid, IDRequest = id, Avsändare = requestdata.Avsändare, Låt = request.Låt, Artist = request.Artist, WillNotPlayBoolProperty = noPlayBoolProp }; model.allRequests = db.Requests.ToList(); return View(model); } else { var model = new MessageViewModel { }; model.allRequests = db.Requests.ToList(); return View(model); } }