Example #1
0
        public Place Get(int id)
        {
            PlaceDAO placeDAO = new PlaceDAO();
            Place    place    = placeDAO.getPlace(id);

            return(place);
        }
Example #2
0
        public Place CreatePlaceAndAddress(PlaceAndAddress place)
        {
            Address adr = AddressDAO.Create(place.Address);

            place.Place.IdAdr = adr.Id;
            return(PlaceDAO.Create(place.Place));
        }
Example #3
0
        public List <Place> GetCategory(String str)
        {
            PlaceDAO     dvO = new PlaceDAO();
            List <Place> dv  = dvO.GetCategory(str);

            return(dv);
        }
Example #4
0
        public List <Place> Get(String str)
        {
            PlaceDAO     dvO = new PlaceDAO();
            List <Place> dv  = dvO.Search2(str);

            return(dv);
        }
Example #5
0
        // GET api/<controller>
        public IEnumerable <Place> Get(String str)
        {
            PlaceDAO     dvO = new PlaceDAO();
            List <Place> dv  = dvO.Search(str);

            return(dv);
        }
Example #6
0
        //En attendant de la résolution de la contrainte on delete cascade en bdd
        public bool DeleteWithCascade(int id)
        {
            if (!AddressDAO.Delete(PlaceDAO.Get(id).IdAdr))
            {
                return(false);
            }

            if (!ReviewDAO.DeleteByPlace(id))
            {
                return(false);
            }

            return(PlaceDAO.Delete(id));
        }
Example #7
0
        public IEnumerable <PlaceAndAddress> GetPlacesAndAddresses()
        {
            IEnumerable <Place> places = PlaceDAO.Query();

            PlaceAndAddress[] placeAndAddresses = new PlaceAndAddress[places.Count()];
            int i = 0;

            foreach (var place in places)
            {
                placeAndAddresses[i] = new PlaceAndAddress(place, AddressDAO.Get(place.IdAdr), PlaceDAO.GetAvgRate(place.Id));
                i++;
            }

            return(placeAndAddresses);
        }
Example #8
0
        public string ApiGetPlaceById(string id)
        {
            PlaceDAO placeDAO = new PlaceDAO();

            Place selectedPlace = placeDAO.SelectPlaceById(id, out string message);

            if (selectedPlace == null)
            {
                return(message);
            }

            var placeToJson = JsonConvert.SerializeObject(selectedPlace);

            return(placeToJson);
        }
Example #9
0
        public IEnumerable <string> ApiGetAllPlaces(int category = 0)
        {
            PlaceDAO _placeDAO = new PlaceDAO();

            List <Place> listaPlaces = _placeDAO.SelectAllPlaces(out string message, category);

            if (listaPlaces == null)
            {
                return new string[] { message }
            }
            ;

            var placesJson = JsonConvert.SerializeObject(listaPlaces);

            return(new string[] { placesJson });
        }
        public async Task <bool> Create(Place Place)
        {
            PlaceDAO PlaceDAO = new PlaceDAO();

            PlaceDAO.Id           = Place.Id;
            PlaceDAO.Name         = Place.Name;
            PlaceDAO.PlaceGroupId = Place.PlaceGroupId;
            PlaceDAO.Radius       = Place.Radius;
            PlaceDAO.Latitude     = Place.Latitude;
            PlaceDAO.Longtitude   = Place.Longtitude;
            PlaceDAO.CreatedAt    = StaticParams.DateTimeNow;
            PlaceDAO.UpdatedAt    = StaticParams.DateTimeNow;
            DataContext.Place.Add(PlaceDAO);
            await DataContext.SaveChangesAsync();

            Place.Id = PlaceDAO.Id;
            await SaveReference(Place);

            return(true);
        }
        public async Task <bool> Update(Place Place)
        {
            PlaceDAO PlaceDAO = DataContext.Place.Where(x => x.Id == Place.Id).FirstOrDefault();

            if (PlaceDAO == null)
            {
                return(false);
            }
            PlaceDAO.Id           = Place.Id;
            PlaceDAO.Name         = Place.Name;
            PlaceDAO.PlaceGroupId = Place.PlaceGroupId;
            PlaceDAO.Radius       = Place.Radius;
            PlaceDAO.Latitude     = Place.Latitude;
            PlaceDAO.Longtitude   = Place.Longtitude;
            PlaceDAO.UpdatedAt    = StaticParams.DateTimeNow;
            await DataContext.SaveChangesAsync();

            await SaveReference(Place);

            return(true);
        }
        public async Task <bool> BulkMerge(List <Place> Places)
        {
            List <PlaceDAO> PlaceDAOs = new List <PlaceDAO>();

            foreach (Place Place in Places)
            {
                PlaceDAO PlaceDAO = new PlaceDAO();
                PlaceDAO.Id           = Place.Id;
                PlaceDAO.Name         = Place.Name;
                PlaceDAO.PlaceGroupId = Place.PlaceGroupId;
                PlaceDAO.Radius       = Place.Radius;
                PlaceDAO.Latitude     = Place.Latitude;
                PlaceDAO.Longtitude   = Place.Longtitude;
                PlaceDAO.CreatedAt    = StaticParams.DateTimeNow;
                PlaceDAO.UpdatedAt    = StaticParams.DateTimeNow;
                PlaceDAOs.Add(PlaceDAO);
            }
            await DataContext.BulkMergeAsync(PlaceDAOs);

            return(true);
        }
Example #13
0
        public PlaceAndAddress GetPlaceAndAddress(int id)
        {
            Place place = PlaceDAO.Get(id);

            return(new PlaceAndAddress(place, AddressDAO.Get(place.IdAdr), PlaceDAO.GetAvgRate(id)));
        }
Example #14
0
        public List <Place> GetAllPlacesByCat(int catId)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.SelectByCat(catId));
        }
Example #15
0
 public ActionResult <Place> Update([FromBody] Place place)
 {
     return(PlaceDAO.Update(place) ? (ActionResult <Place>)Ok() : NotFound());
 }
Example #16
0
        public ActionResult Delete(int id)
        {
            string type = TokenModel.ReadClaimFromRequest(Request, "type");

            return(type == "1" && PlaceDAO.Delete(id) ? (ActionResult)Ok() : BadRequest());
        }
Example #17
0
        public ActionResult <Place> Get(int id)
        {
            Place place = PlaceDAO.Get(id);

            return(place != null ? (ActionResult <Place>)Ok(place) : NotFound("This user does not exists!"));
        }
Example #18
0
        public List <Place> GetBySearch(string substring)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.SearchFor(substring));
        }
Example #19
0
        public Place getavgrating(int id)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.GetAvgRating(id));
        }
Example #20
0
        public int deleteOne(int id)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.DeletePlace(id));
        }
Example #21
0
        public List <Place> GetAllPlaces()
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.GetAll());
        }
Example #22
0
        public List <Place> SelectByRegion(string reg)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.selectregion(reg));
        }
Example #23
0
        public List <Place> GetTop3Rating()
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.gettoprating());
        }
Example #24
0
        public int updateOne(int id)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.UpdatePlace(this, id));
        }
Example #25
0
 public ActionResult <IEnumerable <Place> > Query()
 {
     return(Ok(PlaceDAO.Query()));
 }
Example #26
0
        public Place retrieveOne(int id)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.getOne(id));
        }
Example #27
0
 public ActionResult <Place> Post([FromBody] Place place)
 {
     return(Ok(PlaceDAO.Create(place)));
 }
Example #28
0
        public int AddPlace()
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.Insert(this));
        }
Example #29
0
        public int updaterating(int id, double rating)
        {
            PlaceDAO dao = new PlaceDAO();

            return(dao.UpdateRating(id, rating));
        }