public StopSummary(Stop stop)
 {
     this.ID = stop.ID;
     this.Name = stop.Name;
     this.Description = stop.Description;
     this.Lat = stop.Lat;
     this.Lon = stop.Lon;
 }
 public StopSummary(Stop stop)
 {
     this.ID = stop.ID;
     this.Name = stop.Name;
     this.Description = stop.Description;
     this.Lat = stop.Lat;
     this.Lon = stop.Lon;
     if (stop.Picture != null)
     {
         StopImageURL = System.Web.VirtualPathUtility.ToAbsolute("~/") + String.Format("Stops/Picture/{0}", stop.ID);
     }
     LastTrolleyArrivalTime = new Dictionary<int, DateTime>();
 }
        public ActionResult Edit([Bind(Include = "ID,StopSequence,Name,Description,Lat,Lon")] Stop stop)
        {
            if (ModelState.IsValid)
            {
                var newStop = new Stop();
                newStop.ID = stop.ID;
                db.Stops.Attach(newStop);  // Attach used instead of EntityState.Modified so that only changed fields are saved
                newStop.Lat = stop.Lat;
                newStop.Lon = stop.Lon;
                newStop.Name = stop.Name;
                newStop.Description = stop.Description;

                var file = Request.Files["Picture"];
                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                {
                    string fileName = file.FileName;
                    string fileContentType = file.ContentType;
                    byte[] fileBytes = new byte[file.ContentLength];
                    file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                    newStop.Picture = fileBytes;
                }

                //db.Entry(stop).State = EntityState.Modified;

                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(stop);
        }