Ejemplo n.º 1
0
        public ActionResult Create(HttpPostedFileBase filnavn)
        {
            if (filnavn != null)
            {
                bool skipLine = true;
                foreach (string line in ReadFrom(filnavn))
                {
                   if (skipLine)
                   { // skip first line since it only contains name of header
                       skipLine = false;
                       continue;
                   }
                   var readValues = line.Split(",".ToCharArray());
                    var stop = new Stop
                                   {
                                       Lat = readValues[0],
                                       ZoneId = readValues[1],
                                       Lon = readValues[2],
                                       Url = readValues[3],
                                       StopNumber = (readValues[4]),
                                       Description = readValues[5],
                                       Name = readValues[6],
                                       LocationType = (readValues[7])
                                   };
                   stopRepository.InsertOrUpdate(stop);
                }
                stopRepository.Save();


                return RedirectToAction("Create");
            }

            return View();
        }
Ejemplo n.º 2
0
 public void InsertOrUpdate(Stop stop)
 {
     if (stop.Id == default(int)) {
         // New entity
         context.Stops.Add(stop);
     } else {
         // Existing entity
         context.Entry(stop).State = EntityState.Modified;
     }
 }
        public ActionResult Edit(Stop stop)
        {
            if (ModelState.IsValid) {
                stopRepository.InsertOrUpdate(stop);
                stopRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }