Example #1
0
        public List <SpotModel> SpotGetAll(int id)
        {
            List <SpotModel> spots = new List <SpotModel>();

            // Ouverture de la connexion SQL
            DbConnect.Instance().connection.Open();
            // Création d'une commande SQL
            MySqlCommand cmd = DbConnect.Instance().connection.CreateCommand();

            // Requete SQL
            cmd.CommandText = $"SELECT spot.* FROM spot WHERE id_site = {id}";

            // On veut récupérer les données sous forme d'un liste d'objets
            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    SpotModel spot = new SpotModel(0, "", "", 0);
                    spot.id      = reader.GetInt32(0);
                    spot.nom     = reader.GetString(1);
                    spot.gps     = reader.GetString(2);
                    spot.id_site = reader.GetInt32(3);
                    spots.Add(spot);
                }
            }
            else
            {
                Console.WriteLine("No row found");
            }
            reader.Close();
            DbConnect.Instance().connection.Close();
            return(spots);
        }
        protected void imgBtn_Click(object sender, ImageClickEventArgs e)
        {
            String arg = (String)((ImageButton)sender).CommandArgument;

            String[]  values = arg.Split('|');
            SpotModel spot   = new SpotModel();

            SpotLocation location = new SpotLocation();

            location.state   = values[0];
            location.city    = values[1];
            location.zipcode = values[2];
            spot.location    = location;

            spot.name         = values[3];
            spot.introduction = values[4];
            spot.price        = values[5];

            SpotRootObject rootObj = new SpotRootObject();

            rootObj.key = spot;
            String json = JsonConvert.SerializeObject(rootObj);

            Session["SpotDetails"] = json;
            Response.Redirect("~/Member/SpotDetails");
        }
Example #3
0
        public async Task <IActionResult> PutSpotModel([FromRoute] long id, [FromBody] SpotModel spotModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != spotModel.SpotId)
            {
                return(BadRequest());
            }

            _context.Entry(spotModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpotModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
        private void loadReport()
        {
            staticTimer.reset();
            staticTimer.start("Total");
            Report report = reader.GetReport(selectedAction, selectedAggPos, selectedCllPos, selectedBoardType, selectedBoardSubtype);

            spot = new SpotModel(report);


            if (selectedCategory != null && spot.Categories.Contains((HandCategory)selectedCategory))
            {
                typeList = spot.StrengthTree[(HandCategory)selectedCategory];
            }
            else
            {
                typeList     = null;
                selectedType = null;
            }

            // refresh typelist
            if (selectedType != null && typeList.Contains((HandType)selectedType))
            {
                spot.LoadPlotModel((HandType)selectedType);
                NotifyOfPropertyChange(() => PlotModel);
            }
            else
            {
                selectedType = null;
            }
            NotifyOfPropertyChange(() => Spot);
            staticTimer.stop("Total");
            staticTimer.log("Total");
        }
        public JsonResult GetSpots(Guid id)
        {
            var v = (from spot in _context.Spots
                     join place in _context.Places on spot.PlaceID equals place.ID
                     join user in _context.Users on place.UserID equals user.ID
                     orderby spot.CreationDate descending
                     where spot.IsActive && !spot.IsDone && user.ID != id
                     select new
            {
                spot.ID,
                spot.Title,
                PlaceTitle = place.Title,
                UserName = user.Name,
                spot.LowSal,
                spot.HighSal,
                spot.Phone,
                spot.Description,
                spot.Days,
                spot.Minutes,
                spot.IsPM,
                spot.Gender,
                spot.IsDone
            }).ToList();

            List <SpotModel> spotsResults = new List <SpotModel>();

            for (int i = 0; i < v.Count; i++)
            {
                SpotModel spotModel = new SpotModel();
                spotModel.ID          = v[i].ID;
                spotModel.Title       = v[i].Title;
                spotModel.PlaceTitle  = v[i].PlaceTitle;
                spotModel.UserName    = v[i].UserName;
                spotModel.LowSal      = v[i].LowSal;
                spotModel.HighSal     = v[i].HighSal;
                spotModel.Phone       = v[i].Phone;
                spotModel.Description = v[i].Description;
                spotModel.Days        = v[i].Days;
                spotModel.Minutes     = v[i].Minutes;
                spotModel.IsPM        = v[i].IsPM;
                spotModel.Gender      = v[i].Gender;
                var x = _context.Stareds.Where(y => y.SpotID == v[i].ID && y.UserID == id)?.SingleOrDefault();
                if (x != null)
                {
                    spotModel.IsStared = true;
                }
                else
                {
                    spotModel.IsStared = false;
                }
                spotsResults.Add(spotModel);
            }

            return(Json(spotsResults));
        }
Example #6
0
        public async Task <IActionResult> PostSpotModel([FromBody] SpotModel spotModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Spots.Add(spotModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSpotModel", new { id = spotModel.SpotId }, spotModel));
        }
Example #7
0
        public async Task <BusinessResult <Guid> > CreateSpot(SpotModel SpotModel)
        {
            var spotEntity = Mapper.Map <Spot>(SpotModel);

            spotEntity.CreatedDate = DateTime.Now;
            spotEntity.AreaId      = null;
            spotEntity.PictureUrls = new string[] { "A", "B", "C" };
            DbContext.Spots.Add(spotEntity);

            await DbContext.SaveChangesAsync(true);

            return(CreateSuccessResult(spotEntity.Id));
        }
Example #8
0
        public void GetSpot()
        {
            DataServiceFactory.Connection = _connection;

            SimpleDataService <SpotModel> factory = DataServiceFactory.GetSpotFactory();

            Assert.NotNull(factory);

            Guid spotId = Guid.Parse("610b3ec0-0d70-40a6-9d9f-5167a8135410");

            SpotModel existingSpot = factory.GetItemAsync(spotId).Result;

            Assert.True(existingSpot.SpotMarker.Count > 0);
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            haishengService = new HaishengServiceRef.Service1Client();
            String json = (String)Session["SpotDetails"];

            spot = JsonConvert.DeserializeObject <SpotRootObject>(json).key;

            image.ImageUrl = "../ImgCache/" + spot.name + ".jpg";
            name.Text      = "<Strong><h3>" + spot.name + "</h3></Strong>";
            address.Text   = spot.location.city + ", " + spot.location.state + ", " + spot.location.zipcode;

            introduction.Text = spot.introduction;

            price.Text = "<Strong><h1>" + "$" + spot.price + "</h1></Strong>";

            searchWeather();
            searchPOI();
        }
Example #10
0
        public void SaveFishingArea()
        {
            DataServiceFactory.Connection = _connection;

            SimpleDataService <FishingAreaModel> factory = DataServiceFactory.GetFishingAreaFactory();

            Assert.NotNull(factory);

            Guid areaId = Guid.NewGuid();

            FishingAreaModel tstFishingArea = new FishingAreaModel();

            tstFishingArea.Id            = areaId;
            tstFishingArea.ID_WaterModel = Guid.Parse("2a3eeecf-472c-4b0f-9df0-73386cb3b3f7");
            tstFishingArea.Lat           = 48.46;
            tstFishingArea.Lng           = 13.9267;
            tstFishingArea.FishingArea   = "Donau Obermühl";
            tstFishingArea.IsNew         = true;

            FishingAreaModel success = factory.SaveItemAsync(tstFishingArea).Result;

            Assert.True(success.Id != Guid.Empty);

            FishingAreaModel storedFishingArea = factory.GetItemAsync(areaId).Result;

            Assert.True(storedFishingArea.Id == areaId);


            Guid      spotId  = Guid.NewGuid();
            SpotModel newSpot = new SpotModel();

            newSpot.FishingArea    = storedFishingArea;
            newSpot.Id             = spotId;
            newSpot.Spot           = "Zanderfelsen";
            newSpot.ID_FishingArea = storedFishingArea.Id;
            newSpot.ID_SpotType    = Guid.Parse("1fb8243b-a672-496b-955a-5930cb706250");
            newSpot.IsNew          = true;

            storedFishingArea.Spots.Add(newSpot);

            success = factory.SaveItemAsync(storedFishingArea).Result;

            Assert.True(success.Id != Guid.Empty);
        }
Example #11
0
        public string AddNewSpotItem(TradeSharpConnection context, SpotModel model)
        {
            var result     = string.Empty;
            var newContext = EnsureContext(ref context);

            try
            {
                var spot = new SPOT
                {
                    ComBase       = model.ComBase,
                    ComCounter    = model.ComCounter,
                    Title         = model.Title,
                    CodeFXI       = model.CodeFXI,
                    MinVolume     = model.MinVolume,
                    MinStepVolume = model.MinStepVolume,
                    Precise       = model.Precise,
                    SwapBuy       = model.SwapBuy,
                    SwapSell      = model.SwapSell,
                    Description   = model.Description
                };

                context.SPOT.Add(spot);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Error("AddNewSpotItem()", ex);
                result = ex.Message;
            }
            finally
            {
                if (newContext != null)
                {
                    newContext.Dispose();
                }
            }
            return(result);
        }
        protected void btnAddSpot_Click(Object sender, EventArgs e)
        {
            try
            {
                SpotRootObject rootObj = new SpotRootObject();
                SpotModel      spot    = new SpotModel();

                spot.name = Name.Text;

                MemoryStream ms    = new MemoryStream(Img.FileBytes);
                byte[]       array = ms.ToArray();
                spot.imgBytes = array;
                //spot.imgStr = Encoding.UTF8.GetString(array,0,array.Length);

                SpotLocation location = new SpotLocation();
                location.state   = State.Text;
                location.city    = City.Text;
                location.zipcode = ZipCode.Text;
                spot.location    = location;

                spot.introduction = Introduction.Text;
                spot.price        = Price.Text;

                rootObj.key = spot;
                String  json = JsonConvert.SerializeObject(rootObj);
                Boolean flag = haishengService.addSpot(json);

                if (!flag)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "<script>$('#remindModal').modal('show');</script>", false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        public string EditSpotItem(TradeSharpConnection context, SpotModel model)
        {
            var result     = string.Empty;
            var newContext = EnsureContext(ref context);

            try
            {
                var itemToEdit = context.SPOT.Single(x => x.Title == model.Title);

                itemToEdit.ComBase       = model.ComBase;
                itemToEdit.ComCounter    = model.ComCounter;
                itemToEdit.Title         = model.Title;
                itemToEdit.CodeFXI       = model.CodeFXI;
                itemToEdit.MinVolume     = model.MinVolume;
                itemToEdit.MinStepVolume = model.MinStepVolume;
                itemToEdit.Precise       = model.Precise;
                itemToEdit.SwapBuy       = model.SwapBuy;
                itemToEdit.SwapSell      = model.SwapSell;
                itemToEdit.Description   = model.Description;

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Error("EditSpotItem()", ex);
                result = ex.Message;
            }
            finally
            {
                if (newContext != null)
                {
                    newContext.Dispose();
                }
            }
            return(result);
        }
        public ActionResult EditSpot(SpotModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { status = false, errorString = Resource.ErrorMessageInvalid }, JsonRequestBehavior.AllowGet));
            }

            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var result = spotRepository.EditSpotItem(ctx, model);
                    return(String.IsNullOrEmpty(result) ?
                           Json(new { status = true }, JsonRequestBehavior.AllowGet) :
                           Json(new { status = false, errorString = Resource.ErrorMessage + ": " + result },
                                JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("EditSpot() error", ex);
                return(Json(new { status = false, errorString = Resource.ErrorMessage + ": " + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
 public JsonResult GetSpotsByPlace([FromBody] SearchModel model)
 {
     #region temp
     var temp = (from p in _context.Places
                 join s in _context.Spots on p.ID equals s.PlaceID
                 join u in _context.Users on p.UserID equals u.ID
                 orderby s.CreationDate descending
                 where s.IsActive && p.ID == model.PlaceID &&
                 (model.isAll || model.isStarred ? !s.IsDone : true)
                 select new
     {
         s.ID,
         s.Title,
         PlaceTitle = p.Title,
         UserName = u.Name,
         s.LowSal,
         s.HighSal,
         s.Phone,
         s.Description,
         s.Days,
         s.Minutes,
         s.IsPM,
         s.Gender,
         s.IsDone,
     }).ToList();
     #endregion
     List <SpotModel> spotModels = new List <SpotModel>();
     foreach (var v in temp)
     {
         bool isStarred = false;
         if (model.isStarred)
         {
             if (_context.Stareds.Where(x => x.SpotID == v.ID && x.UserID == model.UserID)?
                 .SingleOrDefault() != null)
             {
                 isStarred = true;
             }
             else
             {
                 continue;
             }
         }
         else
         {
             if (_context.Stareds.Where(x => x.SpotID == v.ID && x.UserID == model.UserID)?
                 .SingleOrDefault() != null)
             {
                 isStarred = true;
             }
         }
         SpotModel ssMM = new SpotModel();
         ssMM.ID          = v.ID;
         ssMM.Title       = v.Title;
         ssMM.PlaceTitle  = v.PlaceTitle;
         ssMM.UserName    = v.UserName;
         ssMM.LowSal      = v.LowSal;
         ssMM.HighSal     = v.HighSal;
         ssMM.Phone       = v.Phone;
         ssMM.Description = v.Description;
         ssMM.Days        = v.Days;
         ssMM.Minutes     = v.Minutes;
         ssMM.IsPM        = v.IsPM;
         ssMM.Gender      = v.Gender;
         ssMM.IsDone      = v.IsDone;
         ssMM.IsStared    = isStarred;
         spotModels.Add(ssMM);
     }
     return(Json(spotModels));
 }