Beispiel #1
0
 public void Put(string Id, Station value)
 {
     if (!_station.UpdateStation(Id, value))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Beispiel #2
0
        public ActionResult Create(Station station)
        {
            if (ModelState.IsValid)
            {
                // TODO: Add insert logic here
                _station.AddStation(station);
                return RedirectToAction("Create");
            }

            {
                return View(station);
            }
        }
Beispiel #3
0
 public Station Post(Station value)
 {
     Station station = _station.AddStation(value);
     return station;
 }
Beispiel #4
0
        public bool UpdateStation(string Id, Station item)
        {
            IMongoQuery query = Query.EQ("_id", Id);

            IMongoUpdate update = Update

                //.Set("UnleadedExtra", item.UnleadedExtra)
                .Set("Petrol", item.Petrol)
                .Set("Diesel", item.Diesel);
                //.Set("UnleadedExtra",item.UnleadedExtra)
               // .Set("LastModified", DateTime.UtcNow)
                //.Set("By", item.By);

            item.LastModified = DateTime.UtcNow;
            WriteConcernResult result = _station.Update(query, update);
            return result.UpdatedExisting;
        }
Beispiel #5
0
 public Station AddStation(Station item)
 {
     item.Id = ObjectId.GenerateNewId().ToString();
     item.LastModified = DateTime.UtcNow;
     _station.Insert(item);
     return item;
 }