Esempio n. 1
0
        public IHttpActionResult PutAreaOfExpertise(int id, AreaOfExpertiseViewModel AreaOfExpertiseViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != AreaOfExpertiseViewModel.Id)
            {
                return(BadRequest());
            }
            AreaOfExpertise AreaOfExpertise = new AreaOfExpertise();

            Mapper.CreateMap <AreaOfExpertiseViewModel, AreaOfExpertise>();
            AreaOfExpertise = Mapper.Map <AreaOfExpertiseViewModel, AreaOfExpertise>(AreaOfExpertiseViewModel);
            db.Entry(AreaOfExpertise).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutAreaOfExpertise(int id, AreaOfExpertise areaOfExpertise)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != areaOfExpertise.AreaOfExpertiseId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("AreaId,PinLocation,GuideId")] AreaOfExpertise areaOfExpertise)
        {
            if (id != areaOfExpertise.AreaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(areaOfExpertise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AreaOfExpertiseExists(areaOfExpertise.AreaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuideId"] = new SelectList(_context.Guides, "GuideId", "GuideId", areaOfExpertise.GuideId);
            return(View(areaOfExpertise));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AreaOfExpertise areaOfExpertise = db.AreaOfExpertise.Find(id);

            db.AreaOfExpertise.Remove(areaOfExpertise);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "AreaOfExpertiseId,AreaOfExpertiseName,AreaOfExpertiseDescription")] AreaOfExpertise areaOfExpertise)
 {
     if (ModelState.IsValid)
     {
         db.Entry(areaOfExpertise).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(areaOfExpertise));
 }
        public ActionResult Create([Bind(Include = "AreaOfExpertiseId,AreaOfExpertiseName,AreaOfExpertiseDescription")] AreaOfExpertise areaOfExpertise)
        {
            if (ModelState.IsValid)
            {
                db.AreaOfExpertise.Add(areaOfExpertise);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(areaOfExpertise));
        }
        public IHttpActionResult GetAreaOfExpertise(int id)
        {
            AreaOfExpertise areaOfExpertise = db.AreaOfExpertise.Find(id);

            if (areaOfExpertise == null)
            {
                return(NotFound());
            }

            return(Ok(areaOfExpertise));
        }
        public IHttpActionResult PostAreaOfExpertise(AreaOfExpertise areaOfExpertise)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AreaOfExpertise.Add(areaOfExpertise);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = areaOfExpertise.AreaOfExpertiseId }, areaOfExpertise));
        }
Esempio n. 9
0
        public async Task <IActionResult> Create([Bind("AreaId,PinLocation,GuideId")] AreaOfExpertise areaOfExpertise)
        {
            if (ModelState.IsValid)
            {
                _context.Add(areaOfExpertise);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuideId"] = new SelectList(_context.Guides, "GuideId", "GuideId", areaOfExpertise.GuideId);
            return(View(areaOfExpertise));
        }
        // GET: AreaOfExpertises/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AreaOfExpertise areaOfExpertise = db.AreaOfExpertise.Find(id);

            if (areaOfExpertise == null)
            {
                return(HttpNotFound());
            }
            return(View(areaOfExpertise));
        }
        public IHttpActionResult DeleteAreaOfExpertise(int id)
        {
            AreaOfExpertise areaOfExpertise = db.AreaOfExpertise.Find(id);

            if (areaOfExpertise == null)
            {
                return(NotFound());
            }

            db.AreaOfExpertise.Remove(areaOfExpertise);
            db.SaveChanges();

            return(Ok(areaOfExpertise));
        }
Esempio n. 12
0
        public IHttpActionResult PostAreaOfExpertise(AreaOfExpertiseViewModel AreaOfExpertiseViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AreaOfExpertise AreaOfExpertise = new AreaOfExpertise();

            Mapper.CreateMap <AreaOfExpertiseViewModel, AreaOfExpertise>();
            AreaOfExpertise = Mapper.Map <AreaOfExpertiseViewModel, AreaOfExpertise>(AreaOfExpertiseViewModel);

            db.AreaOfExpertise.Add(AreaOfExpertise);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = AreaOfExpertise.Id }, AreaOfExpertise));
        }