public IActionResult AreasConhecimento(PageDataViewModel <AreaConhecimento> model)
        {
            IEnumerable <AreaConhecimento> data = null;

            switch (model.FilterType)
            {
            case FilterType.ById:
                var id     = Int64.Parse(model.FilteValue);
                var entity = _Service.GetAreaConhecimentoById(id);

                if (entity != null)
                {
                    data = new AreaConhecimento[] { entity };
                }
                else
                {
                    data = new AreaConhecimento[] { };
                }
                break;

            case FilterType.ByName:
                data = _Service.GetAreasConhecimento(model.FilteValue);
                break;
            }

            model.Total = data.Count();
            model.Data  = data;

            return(View(model));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AreaConhecimento areaConhecimento = db.AreasConhecimento.Find(id);

            db.AreasConhecimento.Remove(areaConhecimento);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Nome,Ativo")] AreaConhecimento areaConhecimento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(areaConhecimento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(areaConhecimento));
 }
        public ActionResult Create([Bind(Include = "Id,Nome,Ativo")] AreaConhecimento areaConhecimento)
        {
            if (ModelState.IsValid)
            {
                db.AreasConhecimento.Add(areaConhecimento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(areaConhecimento));
        }
Пример #5
0
        //_____________________________________________

        public void SetAreaConhecimento(AreaConhecimento AreaConhecimento)
        {
            try
            {
                this.AreaConhecimento = AreaConhecimento;
                this.GetAreaConhecimento();
            }
            catch (Exception ex)
            {
                throw new Exception(nameof(ex.Message));
            }
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AreaConhecimento areaConhecimento = db.AreasConhecimento.Find(id);

            if (areaConhecimento == null)
            {
                return(HttpNotFound());
            }
            return(View(areaConhecimento));
        }
        public AreaConhecimento GetAreaConhecimentoById(long id)
        {
            Task <string> task = Get(
                $"{_ApiServiceName}/GetAreaConhecimentoById",
                new Dictionary <string, string>()
            {
                { "id", id.ToString() }
            }
                );

            task.Wait();

            string content = task.Result;

            if (string.IsNullOrEmpty(content))
            {
                return(null);
            }

            AreaConhecimento areaConhecimento = JsonConvert.DeserializeObject <AreaConhecimento>(content);

            return(areaConhecimento);
        }