示例#1
0
        public async Task <IHttpActionResult> PutSugerirPOI(int id, SugerirPOI sugerirPOI)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sugerirPOI.SugerirPoiID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public async Task <IHttpActionResult> PutCategoria(int id, Categoria categoria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categoria.CategoriaID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> Create([Bind(Include = "LocalID,GPS_Lat,GPS_Long,Nome")] Local local)
        {
            if (ModelState.IsValid)
            {
                db.Locals.Add(local);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(local));
        }
示例#4
0
        public async Task <ActionResult> Create([Bind(Include = "PointOfInterestID,Nome,Descricao,LocalID")] PointOfInterest pointOfInterest)
        {
            pointOfInterest.CriadorID = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                db.PointsOfInterest.Add(pointOfInterest);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.LocalID = new SelectList(db.Locals, "LocalID", "Nome", pointOfInterest.LocalID);
            return(View(pointOfInterest));
        }
        public async Task <IHttpActionResult> PutPointOfInterest(int id, PointOfInterest pointOfInterest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pointOfInterest.PointOfInterestID)
            {
                return(BadRequest());
            }

            if (!pointOfInterest.Criador.Id.Equals(User.Identity.GetUserId()))
            {
                return(Unauthorized());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }