public async Task<IHttpActionResult> AddPlace(VMPlace Plc)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest("Model state is not valid");
            }
            

            Town t = _db.Towns.FirstOrDefault(dis => dis.TownName == Plc.TownName);
            if (t == null)
            {
                return BadRequest("Town is not difined. Please add a difined town that suggest by the list");
            }

            string[] strings = JsonConvert.DeserializeObject<string[]>(Plc.CategoryName);

            List<EventCategory> cta = new List<EventCategory>();


            if (strings != null)
            {
                for (int i = 0; i < strings.Count(); i++)
                {
                    string n = strings[i];
                    //.Select(g => new CatId { Id = t.Id })
                    EventCategory c = _db.EventCategories.Where(cat => cat.CategotyName == n).FirstOrDefault();
                    if (c == null)
                    {

                        return BadRequest("Category is not define. Please add correct category");
                    }

                    cta.Add(c);
                }
            }

            Event place = new Event();
            place.Id = Guid.NewGuid();
            place.Address = Plc.Address;
            place.Description = Plc.Discription;
            place.Latitude = Plc.Latitude;
            place.Longitude = Plc.Longitude;
            place.EventName = Plc.PlaceName;
            place.QuickFacts = Plc.QFacts;
            place.TownId = t.Id;
            place.EventCategories = cta;
            _db.Events.Add(place);
            await _db.SaveChangesAsync();


            return Ok("Successfully added recode");

        }
 public IHttpActionResult DeletePlace(VMPlace vmp)
 {
     if (vmp.Id != null)
     {
         Guid _guid = Guid.Parse(vmp.Id);
         Place p = _db.Places.FirstOrDefault(plc => plc.Id == _guid);
         if (p != null)
         {
             _db.Places.Remove(p);
             _db.SaveChanges();
             return Ok();
         }
         else
         {
             return BadRequest();
         }
     }
     else
     {
         return BadRequest();
     }
 }
 public IHttpActionResult EditPlace(VMPlace plc)
 {
     if (ModelState.IsValid)
     {
         Town t = _db.Towns.FirstOrDefault(dis => dis.TownName == plc.TownName);
         if (t != null)
         {
             Guid guid = Guid.Parse(plc.Id);
             Place p = _db.Places.FirstOrDefault(pl => pl.Id == guid);
             if (p != null)
             {
                 p.Address = plc.Address;
                 p.Description = plc.Discription;
                 p.Latitude = plc.Latitude;
                 p.Longitude = plc.Longitude;
                 p.PlaceName = plc.PlaceName;
                 p.QuickFacts = plc.QFacts;
                 p.TownId = t.Id;
                 _db.SaveChanges();
                 return Ok();
             }
             else
             {
                 return BadRequest("Recode update fail. Please try again");
             }
         }
         else
         {
             return BadRequest("Recode update fail. Please try again");
         }
     }
     else
     {
         return BadRequest("Recode update fail. Please try again");
     }
 }