Exemple #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));
        }
Exemple #2
0
        //public IHttpActionResult GetAreaOfExpertise(int id)
        public AreaOfExpertiseViewModel GetAreaOfExpertise(int id)

        {
            AreaOfExpertiseViewModel AreaOfExpertiseViewModel = new AreaOfExpertiseViewModel();

            NGOdata.AreaOfExpertise GetAreaOfExpertise;

            GetAreaOfExpertise = db.AreaOfExpertise.Where(x => x.Id == id).FirstOrDefault();

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

            return(AreaOfExpertiseViewModel);
        }
Exemple #3
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));
        }
Exemple #4
0
        // GET: api/AreaOfExpertise
        public List <AreaOfExpertiseViewModel> GetAreaOfExpertise()
        {
            var AreaOfExpertiseList = db.AreaOfExpertise.ToList();

            List <AreaOfExpertiseViewModel> AreaOfExpertiseViewModelList = new List <AreaOfExpertiseViewModel>();

            foreach (var item in AreaOfExpertiseList)
            {
                AreaOfExpertiseViewModel AreaOfExpertiseViewModel = new AreaOfExpertiseViewModel();

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

                AreaOfExpertiseViewModelList.Add(AreaOfExpertiseViewModel);
            }


            return(AreaOfExpertiseViewModelList);
        }