예제 #1
0
        static public List <Zone> GetAllZones()
        {
            List <Zone> zonetemp = null;

            using (ZoneRepository zonerepo = new ZoneRepository())
            {
                zonetemp = (List <Zone>)zonerepo.GetAll();
                foreach (Zone zone in zonetemp)
                {
                    zonerepo.context.Entry(zone).State = EntityState.Detached;
                }
            }

            return(zonetemp);
        }
예제 #2
0
 public IActionResult Get()
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <ZoneModel> List = repo.GetAll().Select(Zone => Zone?.MapTo <ZoneModel>());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(List)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }