public async Task <IActionResult> GetById(int id)
        {
            var item = await _repository.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete Area by id
        /// </summary>
        public void DeleteArea(long areaId)
        {
            Area dbversion = areaRepository.Find((int)areaId);

            ValidateBeforeDeletion(areaId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Area with Id {0} not found!", areaId));
            }
            areaRepository.Delete(dbversion);
            areaRepository.SaveChanges();
        }
Exemplo n.º 3
0
        public List <bx_area> Find()
        {
            var key = "ExternalApi_Area_Find";

            lock (key)
            {
                var cachelst = CacheProvider.Get <List <bx_area> >(key);
                if (cachelst == null)
                {
                    var lst = _areaRepository.Find();
                    CacheProvider.Set(key, lst);
                    return(lst);
                }
                return(cachelst);
            }
        }
Exemplo n.º 4
0
 // GET: /Areas/Details/5
 public ViewResult Details(long id)
 {
     return(View(areaRepository.Find(id)));
 }