Beispiel #1
0
        public IHttpActionResult PutNote(Guid id, Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != note.Id)
            {
                return(BadRequest());
            }

            db.Entry(note).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
 public ActionResult Edit(VacationDisp vacation)
 {
     if (ModelState.IsValid)
     {
         var MyVacation = db.Vacations.Find(vacation.VacationID);
         MyVacation.CopyData(vacation);
         foreach (var item in db.VacationsToSequences)
         {
             if (item.VacationID == vacation.VacationID)
             {
                 db.Entry(item).State = System.Data.Entity.EntityState.Deleted;
             }
         }
         foreach (var item in vacation.Sequences)
         {
             if (item.Selected)
             {
                 db.VacationsToSequences.Add(new VacationToSequence(vacation.VacationID, item.Id));
             }
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vacation));
 }
Beispiel #3
0
        public async Task <IActionResult> PutSegment([FromRoute] int id, [FromBody] Segment segment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != segment.Id)
            {
                return(BadRequest());
            }

            _context.Entry(segment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SegmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "RegionID,Name,DestinationID")] Region region)
 {
     if (ModelState.IsValid)
     {
         db.Entry(region).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(region));
 }
Beispiel #5
0
        // POST: Sequences/Remove/5?Seqnr=7
        //    [HttpPost]
        //    [ValidateAntiForgeryToken]
        public ActionResult Remove(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int?h = Convert.ToInt32(HttpContext.Request.QueryString["Seqnr"]);

            if (h == null)
            {
                return(HttpNotFound());
            }

            IEnumerable <SequenceToActivity> list = (from sa in db.SequencesToActivities where sa.SequenceID == id & sa.Seqnr >= h select sa);

            foreach (var item in list)
            {
                db.Entry(item).State = System.Data.Entity.EntityState.Deleted;
            }
            db.SaveChanges();
            return(RedirectToAction("Edit", new { Id = id }));
        }
Beispiel #6
0
        public async Task <IActionResult> PutTrip(TripModel m)
        {
            var t = await _DB.Trips.FindAsync(m.Id);

            if (t == null)
            {
                return(NotFound());
            }
            if (!CanEditOrDelete(_User.UserId, m.UserId))
            {
                return(NotFound()); //for internal should be NotAuthorized, but for public security reasons we should return zero info about request.
            }
            //update entry
            t.DateUTC     = m.DateUTC;
            t.Destination = m.Destination;
            t.Country     = m.Country;
            t.Title       = m.Title;
            t.UserId      = m.UserId;

            _DB.Entry(t).State = EntityState.Modified;

            try
            {
                await _DB.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TripExists(m.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public void Update(CommentPlace item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
Beispiel #8
0
 public async void UpdateTrip(int tripId, Trip trip)
 {
     context.Entry(trip).State = EntityState.Modified;
     await context.SaveChangesAsync();
 }
Beispiel #9
0
 public void Update(Track item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
Beispiel #10
0
 public void Update(Picture item)
 {
     db.Entry(item).State = EntityState.Modified;
 }