public ActionResult DreamList(int id)
 {
     if (ibo != null)
     {
         List <Dream> dreams = IBOVirtualAPI.GetDreamsUserLevel(ibo.IBONum, id.ToString());
         if ((dreams.Count > 0) || (id == 0))
         {
             ViewBag.dreamLevel = id;
             ViewBag.nextLevel  = id + 1;
             List <Dream> dreamsLevel = IBOVirtualAPI.GetDreamsUserLevel(ibo.IBONum, (id + 1).ToString());
             Dictionary <Timeframe, Dream> timeframeDreams = new Dictionary <Timeframe, Dream>();
             List <Timeframe> timeframes = IBOVirtualAPI.GetTimeFrames(id, ibo.languageId);
             Timeframe        last       = timeframes.Last();
             if (dreamsLevel.Count < 1)
             {
                 ViewBag.lastItem = last;
             }
             foreach (Timeframe time in timeframes)
             {
                 Dream dream = (from d in dreams
                                where d.timeframeId == time.timeframeId
                                select d).FirstOrDefault();
                 timeframeDreams.Add(time, dream);
             }
             return(PartialView(timeframeDreams));
         }
     }
     return(null);
 }
        /// <summary>
        /// Logic for button (save new dream in database and on dream page)
        /// </summary>
        private void add_Click(object sender, RoutedEventArgs e)
        {
            if (dbContext.Set <Dream>().Where(d => d.UserId == controller.user.Id).ToList().Count != 0)
            {
                dbContext.Set <Dream>().RemoveRange(dbContext.Set <Dream>().Where(d => d.UserId == controller.user.Id));
            }
            dreamPage.dreamName              = DreamName.Text;
            dreamPage.dreamPrice             = Double.Parse(DreamPrice.Text);
            dreamPage.dreamNameLabel.Content = dreamPage.dreamName + " " + dreamPage.dreamPrice;

            if (Double.TryParse(DreamPrice.Text, out double amount))
            {
                Dream dream = new Dream();
                dream.UserId = controller.user.Id;
                dream.Name   = DreamName.Text;
                dream.Price  = amount;

                dbContext.Set <Dream>().Add(dream);
                dbContext.SaveChanges();

                dreamPage.UpdateProgressBar();
                this.Close();
            }
            else
            {
                MessageBox.Show("Wrong price entered");
            }
        }
Example #3
0
    public static void test()
    {
        ProblemSize ps = new()
        {
            chain_num = 10,
            cr_num    = 3,
            gen_num   = 10,
            pair_num  = 3,
            par_num   = 10
        };

        ProblemValue pv = new()
        {
            chain_filename         = "problem0_chain00.txt",
            gr_filename            = "problem0_gr.txt",
            gr_threshold           = 1.2,
            jumpstep               = 5,
            printstep              = 10,
            restart_read_filename  = "",
            restart_write_filename = "problem0_restart.txt",
            limits = new double[ps.par_num * 2]
        };

        for (int j = 0; j < ps.par_num; j++)
        {
            pv.limits[0 + j * 2] = -10.0;
            pv.limits[1 + j * 2] = +10.0;
        }

        Dream.dream(ref ps, ref pv, prior_sample, prior_density, sample_likelihood);
    }

    private static Dream.DensityResult prior_density(int par_num, double[] zp, int zpIndex = 0)
Example #4
0
        public void CanSaveDream()
        {
            int      pointsActual;
            int      durationActual;
            DateTime date;
            var      dream = new Dream {
                Duration = 12345, Points = 12312
            };

            new DreamDb().SaveDream(dream);

            using (SQLiteConnection c = new SQLiteConnection(ConfigurationManager.ConnectionStrings["sqllite"].ConnectionString))
            {
                c.Open();
                using (SQLiteCommand cmd = new SQLiteCommand("select * from Dream", c))
                {
                    using (SQLiteDataReader r = cmd.ExecuteReader())
                    {
                        r.Read();
                        pointsActual   = Convert.ToInt32(r["Points"]);
                        durationActual = Convert.ToInt32(r["DurationMs"]);
                        date           = Convert.ToDateTime(r["Date"]);
                    }
                }
            }

            Assert.AreEqual(dream.Points, pointsActual);
            Assert.AreEqual(dream.Duration, durationActual);
            Assert.AreEqual(date.Day, DateTime.Now.Day);

            Assert.AreEqual(date.Month, DateTime.Now.Month);
            Assert.AreEqual(date.Year, DateTime.Now.Year);
            Assert.AreEqual(date.Hour, DateTime.Now.Hour);
            Assert.AreEqual(date.Minute, DateTime.Now.Minute);
        }
Example #5
0
        public ActionResult Create([Bind(Include = "ID,Date,Dream1,Person,DidMeditation,Links,Longitude,Latitude")] Dream dream)
        {
            //if (ModelState.IsValid)
            //{
            dream.ID = Guid.NewGuid();

            if (dream.Date.Equals(new DateTime()) && ModelState["Date"].Value != null)
            {
                var etempDT =
                    ModelState.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
                    .ToArray()
                    .First(m => m.Key == "Date")
                    .Value.Value.AttemptedValue;
                if (!etempDT.Length.Equals(0))
                {
                    dream.Date = Convert.ToDateTime(FixFuckenDate(etempDT));
                }
            }

            //dream.Dream1 = dream.Dream1;

            db.Dreams.Add(dream);
            db.SaveChanges();
            return(RedirectToAction("Index"));

            // }

            ViewBag.Person = new SelectList(db.People, "ID", "PersonName", dream.Person);
            return(View(dream));
        }
        public ActionResult Details(int id)
        {
            ViewBag.areas = new SelectList(areas, "areaId", "title");
            Dream dream = IBOVirtualAPI.Get <Dream>(id.ToString());

            return(PartialView(dream));
        }
Example #7
0
        public long Add(Dream dream)
        {
            var entry = _dreams.Add(dream);

            Context.SaveChanges();

            return(entry.Entity.Id);
        }
 public CalendarEvent(Dream evt)
 {
     this.title    = string.Concat("Dream:  ", evt.dream1.Substring(0, evt.dream1.Length <= 30 ? evt.dream1.Length : 30));
     this.allDay   = true;
     this.start    = evt.datetime.ToString("s");
     this.url      = string.Concat("/Dreams/EditDream/", evt.dreamId.ToString());
     this.editable = false;
 }
Example #9
0
        public async Task DreamersController_PUT_UpdateDreamer()
        {
            //Arrange
            var category  = _fixture.DreamCategoryBuilder(10).Create();
            var category2 = _fixture.DreamCategoryBuilder(15).Create();
            await IntegrationTestsFixture.DatabaseContext.DreamCategories.AddAsync(category);

            await IntegrationTestsFixture.DatabaseContext.DreamCategories.AddAsync(category2);

            await IntegrationTestsFixture.DatabaseContext.SaveChangesAsync();

            var dream = new Dream
            {
                DisplayName     = "T",
                Age             = 2,
                DreamUrl        = "https://mam-marzenie.pl/marzenie/1",
                Tags            = "tag1",
                DreamCategoryId = category.DreamCategoryId
            };
            await IntegrationTestsFixture.DatabaseContext.Dreams.AddAsync(dream);

            await IntegrationTestsFixture.DatabaseContext.SaveChangesAsync();

            IntegrationTestsFixture.SetUserContext(new User {
                Role = UserRoleEnum.Coordinator
            });
            var request = new UpdateDreamRequest
            {
                DreamId     = dream.DreamId,
                DisplayName = "Test",
                Age         = 3,
                DreamUrl    = "https://mam-marzenie.pl/marzenie/2",
                Tags        = "tag1, tag2",
                CategoryId  = category2.DreamCategoryId
            };

            //Act
            var _ = await Client.PutAsync("/api/dreams", request.WithJsonContent().json).AsResponse <UpdateDreamResponse>();

            IntegrationTestsFixture.SetUserContext(new User {
                Role = UserRoleEnum.Admin
            });
            var queryResponse = await Client.GetDreams();


            queryResponse.Should().NotBeNull();
            queryResponse.Dreams.Count.Should().Be(1);
            queryResponse.Dreams.Should().SatisfyRespectively(x =>
            {
                x.DreamId.Should().Be(dream.DreamId);
                x.DisplayName.Should().Be(request.DisplayName);
                x.Age.Should().Be(request.Age);
                x.DreamUrl.Should().Be(request.DreamUrl);
                x.Tags.Should().Be(request.Tags);
                x.DreamCategory.Should().NotBeNull();
                x.DreamCategory.DreamCategoryId.Should().Be(request.CategoryId);
            });
        }
Example #10
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Dream dream = db.Dreams.Find(id);

            dream.Deleted = true;
            //db.Dreams.Remove(dream);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public DreamResponse(Dream dream)
 {
     if (dream != null)
     {
         Id      = dream.Id;
         Length  = dream.Length;
         Quality = dream.Quality;
     }
 }
 public ActionResult NewDream(Dream model)
 {
     try
     {
         bool result = IBOVirtualAPI.Create <Dream>(model);
     }
     catch { }
     return(RedirectToAction("Index"));
 }
 public ActionResult DisplayDream(Dream model, bool last)
 {
     ViewBag.area      = (from area in areas where area.areaId == model.areaId select area.title).FirstOrDefault();
     ViewBag.completed = model.achieved == true ? " " + TextResources.Businesslms.achieved + " " : " " + TextResources.Businesslms.WorkingOn + " ";
     ViewBag.etaMsg    = model.achieved == true ? " " + TextResources.Businesslms.Before + " " : " " + TextResources.Businesslms.Until + " ";
     ViewBag.eta       = String.Format("{0:dddd dd MMMM yyyy}", model.datetime);
     ViewBag.last      = last;
     return(PartialView(model));
 }
Example #14
0
        public void SetUp()
        {
            var screenReader = Substitute.For <INMZPointsScreenReader>();

            screenReader.ScreenToNMZPoints().ReturnsForAnyArgs("1231");

            dream = new Dream {
                Calculator            = Substitute.For <IPointsCalculator>(),
                NMZPointsScreenReader = screenReader,
            };
        }
        public void DreamIsNullcheck()
        {
            Dream dream = null;

            Assert.Multiple(() =>
            {
                Assert.That(dream, Is.EqualTo(null));
                dream = new Dream();
                Assert.That(dream, !Is.EqualTo(null));
            });
        }
Example #16
0
 /// <summary>
 /// Invoked when the Submit button clicked
 /// </summary>
 /// <param name="obj">The object</param>
 private void SubmitClicked(Object obj)
 {
     var dream = new Dream()
     {
         Title       = this.DreamTitle,
         Category    = this.SelectedCategory.Description,
         Description = this.Description,
         Volunteer   = this.SelectedVolunteer
                       //add this dream to a dreamer
     };
 }
        public Dream GetDream(int id)
        {
            Dream dream = db.Dreams.Find(id);

            if (dream == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(dream);
        }
Example #18
0
        public ActionResult Edit([Bind(Include = "ID,Date,Dream1,Person")] Dream dream)
        {
            //if (ModelState.IsValid)
            //{
            db.Entry(dream).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));

            //}
            ViewBag.Person = new SelectList(db.People, "ID", "PersonName", dream.Person);
            return(View(dream));
        }
 public ActionResult EditDream(Dream model)
 {
     try
     {
         string result = IBOVirtualAPI.Update <Dream>(model.dreamId.ToString(), model);
         return(Json(new { success = true }));
     }
     catch
     {
         return(Json(new { success = false }));
     }
 }
Example #20
0
        public IHttpActionResult GetDream(int id)
        {
            var identity = (ClaimsIdentity)User.Identity;
            int l_userId = Int32.Parse(identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Single().Value);

            Dream dream = (from row in db.DreamContext where row.m_id == id && row.m_userId == l_userId select row).Single <Dream>();

            if (dream == null)
            {
                return(NotFound());
            }
            return(Ok(dream));
        }
        public ActionResult NewDream(int timeframeId, int days, string IBONum, int dreamLevel)
        {
            ViewBag.areas      = new SelectList(areas, "areaId", "title");
            ViewBag.formName   = string.Concat("createIBOForm", dreamLevel.ToString(), timeframeId.ToString());
            ViewBag.uploadName = string.Concat("file_upload", dreamLevel.ToString(), timeframeId.ToString());
            Dream dream = new Dream();

            dream.IBONum      = ibo.IBONum;
            dream.dreamLevel  = dreamLevel;
            dream.timeframeId = timeframeId;
            dream.datetime    = DateTime.Now.AddDays(days);
            return(PartialView(dream));
        }
        public void LoadDreamSettingsTest(string ServerInstruction, bool IsPermament, bool IsModern, string ExpectedValue)
        {
            Dream     TestDream = new Dream();
            LoadDream loadDream = new LoadDream(ServerInstruction);

            TestDream.Load(loadDream);
            Assert.Multiple(() =>
            {
                Assert.That(TestDream.FileName, Is.EqualTo(ExpectedValue), $"Drean Cache file{TestDream.FileName}");
                Assert.That(TestDream.IsModern, Is.EqualTo(IsModern), $"IsModern {TestDream.IsModern}");
                Assert.That(TestDream.IsPermanent, Is.EqualTo(IsPermament), $"IsPermament {TestDream.IsPermanent}");
            });
        }
Example #23
0
        public JsonResult Edit(DreamCustom model)
        {
            if (ModelState.IsValid)
            {
                CheckConnection();
                Dream dreams = _db.Dreams.Where(x => x.ID == model.Id).FirstOrDefault();
                dreams.Title       = model.Title;
                dreams.Description = model.Description;
                dreams.CreateDate  = model.CreateDate;
                dreams.Lat         = model.Lat;
                dreams.Long        = model.Long;
                dreams.isPublic    = model.isPublic;
                dreams.Lang        = model.Lang;

                _db.DreamAndCategories.RemoveRange(_db.DreamAndCategories.Where(x => x.DreamID == dreams.ID));
                foreach (var cat in model.Categories)
                {
                    dreams.DreamAndCategories.Add(new DreamAndCategory()
                    {
                        CategoryID = cat
                    });
                }
                foreach (var tagId in _db.DreamAndTags.Where(x => x.DreamID == dreams.ID).Select(x => x.TagID))
                {
                    _db.Tags.Find(tagId);
                    _db.Tags.Remove(_db.Tags.Find(tagId));
                }
                _db.DreamAndTags.RemoveRange(_db.DreamAndTags.Where(x => x.DreamID == dreams.ID));

                foreach (var tag in model.Tags)
                {
                    var _tag = _db.Tags.Add(new Tag()
                    {
                        Name = tag
                    });
                    dreams.DreamAndTags.Add(new DreamAndTag()
                    {
                        Tag = _tag
                    });
                }

                _db.SaveChanges();
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors.Select(e => e.ErrorMessage));
                return(Json(errors, JsonRequestBehavior.AllowGet));
            }
        }
Example #24
0
        // GET: Dreams/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dream dream = db.Dreams.Find(id);

            if (dream == null)
            {
                return(HttpNotFound());
            }
            return(View(dream));
        }
Example #25
0
        public static Dream ParseDream(Dream model)
        {
            Dream newObject = new Dream();

            newObject.IBONum      = model.IBONum;
            newObject.dream1      = model.dream1;
            newObject.achieved    = model.achieved;
            newObject.areaId      = model.areaId;
            newObject.datetime    = model.datetime;
            newObject.picture     = model.picture;
            newObject.dreamLevel  = model.dreamLevel + 1;
            newObject.timeframeId = model.timeframeId + 1;
            return(newObject);
        }
 public ActionResult MoreDreams(int id)
 {
     try
     {
         Dream dream = IBOVirtualAPI.Get <Dream>(id.ToString());
         if (dream != null)
         {
             Dream newDream = ModelParser.ParseDream(dream);
             bool  result   = IBOVirtualAPI.Create <Dream>(newDream);
         }
     }
     catch { }
     return(RedirectToAction("Index"));
 }
Example #27
0
    void genDream()
    {
        Dream r = new Dream();

        height = UnityEngine.Random.Range(32, 46);
        width  = 250;
        map    = new int[height, width];
        r.setMap(map);
        map     = r.genMap();
        tileMap = fillTileMap(map);
        renderMap(tileMap);
        xStart = r.sx * spaceMod;
        yStart = r.sy * spaceMod;
    }
Example #28
0
        // GET: Dreams/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dream dream = db.Dreams.Find(id);

            if (dream == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Person = new SelectList(db.People, "ID", "PersonName", dream.Person);
            return(View(dream));
        }
Example #29
0
        public void SaveDream(Dream dream)
        {
            using (SQLiteConnection c = new SQLiteConnection(ConfigurationManager.ConnectionStrings["sqllite"].ConnectionString))
            {
                c.Open();
                using (SQLiteCommand command = new SQLiteCommand("INSERT INTO Dream (DurationMs, Points, Date) VALUES (@durationms,@points,@date);", c))
                {
                    command.Parameters.AddWithValue("@durationms", dream.Duration);
                    command.Parameters.AddWithValue("@points", dream.Points);
                    command.Parameters.AddWithValue("@date", DateTime.Now);

                    command.ExecuteNonQuery();
                }
            }
        }
Example #30
0
        public void SaveDream(Dream dream)
        {
            using (SQLiteConnection c = new SQLiteConnection(ConfigurationManager.ConnectionStrings["sqllite"].ConnectionString))
            {
                c.Open();
                using (SQLiteCommand command = new SQLiteCommand("INSERT INTO Dream (DurationMs, Points, Date) VALUES (@durationms,@points,@date);", c))
                {
                    command.Parameters.AddWithValue("@durationms", dream.Duration);
                    command.Parameters.AddWithValue("@points", dream.Points);
                    command.Parameters.AddWithValue("@date", DateTime.Now);

                    command.ExecuteNonQuery();
                }
            }
        }
Example #31
0
        public async void EndingADreamSavesItsDuration()
        {
            dream = new Dream();
            var screenReader = Substitute.For <INMZPointsScreenReader>();

            screenReader.ScreenToNMZPoints().ReturnsForAnyArgs("1048576");
            dream.NMZPointsScreenReader = screenReader;

            dream.Start();
            await Task.Delay(100);

            dream.End();

            Assert.That(Math.Abs(dream.Duration - 100) < 50, "Expected 100, was actually " + dream.Duration);
        }
Example #32
0
 private void Invoke(Dream.Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
 {
     lock(this) {
         if(_failed) {
             _log.DebugFormat("we've already failed, no point checking more expectations");
             response.Return(DreamMessage.InternalError());
             return;
         }
         _log.DebugFormat("{0}={1}", verb, uri);
         XDoc requestDoc = request.HasDocument ? request.ToDocument() : null;
         if(_expectations.Count == _current) {
             _log.DebugFormat("excess");
             ExcessInterception excess = new ExcessInterception();
             _excess.Add(excess);
             ;
             response.Return(excess.Call(verb, uri, requestDoc));
             return;
         }
         AutoMockInvokeExpectation expectation = _expectations[_current];
         expectation.Call(verb, uri, request);
         if(!expectation.Verify()) {
             AddFailure(_expectations[_current].VerificationFailure);
             _log.DebugFormat("got failure, setting reset event ({0})", _current);
             _failed = true;
             _resetEvent.Set();
             response.Return(DreamMessage.BadRequest("expectation failure"));
             return;
         }
         _current++;
         _log.DebugFormat("expected");
         if(_expectations.Count == _current) {
             _log.DebugFormat("setting reset event");
             _resetEvent.Set();
         }
         response.Return(expectation.GetResponse());
     }
 }