Example #1
0
 public void SetValues(Treat course)
 {
     if (CourseText) CourseText.text = course.Name;
     if (MoneyText) MoneyText.text = course.Money.ToString();
     if (IqText) IqText.text = course.Heath.ToString();
     if (HourText) HourText.text = (course.Hours - course.PrecessedHours).ToString();
     if (TimeText) TimeText.text = "";// course.Working.WorkString;
 }
Example #2
0
 public void StartTreat(int treatTag)
 {
     switch (treatTag)
     {
         case 0:
             CurrentTreat = TreatQuick;
             break;
         case 1:
             CurrentTreat = TreatMedium;
             break;
         case 2:
             CurrentTreat = TreatLong;
             break;
     }
     StartWorking();
 }
Example #3
0
        public async Task <ActionResult> Create(Treat treat, int FlavorId)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            treat.User = currentUser;
            _db.Treats.Add(treat);
            if (FlavorId != 0)
            {
                _db.TreatFlavors.Add(new TreatFlavor()
                {
                    TreatId = treat.TreatId, FlavorId = FlavorId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Details", "Treats", new { id = treat.TreatId }));
        }
 public ActionResult Edit(Treat treat, int FlavorId)
 {
     if (FlavorId != 0)
     {
         bool tf = _db.FlavorTreat.Any(x => x.FlavorId == FlavorId && x.TreatId == treat.TreatId);
         if (!tf)
         {
             _db.FlavorTreat.Add(new FlavorTreat()
             {
                 FlavorId = FlavorId, TreatId = treat.TreatId
             });
         }
     }
     _db.Entry(treat).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #5
0
 public ActionResult AddFlavor(Treat treat, int FlavorId)
 {
     if (FlavorId != 0)
     {
         var returnedJoin = _db.TreatFlavor
                            .Any(join => join.FlavorId == FlavorId && join.TreatId == treat.TreatId);
         if (!returnedJoin)
         {
             _db.TreatFlavor.Add(new TreatFlavor()
             {
                 TreatId = treat.TreatId, FlavorId = FlavorId
             });
         }
     }
     _db.SaveChanges();
     return(RedirectToAction("Details", new { id = treat.TreatId }));
 }
        public async Task <ActionResult> Index(Treat treat, int FlavorId)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            treat.User = currentUser;
            _db.Treats.Add(treat);
            if (FlavorId != 0)
            {
                _db.FlavorTreat.Add(new FlavorTreat()
                {
                    FlavorId = FlavorId, TreatId = treat.TreatId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index", "FlavorTreat"));
        }
Example #7
0
        public ActionResult AddFlavor(Treat treat, int FlavorId)
        {
            var existingConnection = _db.FlavorTreat.FirstOrDefault(join => join.TreatId == treat.TreatId && join.FlavorId == FlavorId);

            if (existingConnection != null)
            {
                return(RedirectToAction("Details", new { id = treat.TreatId }));
            }
            if (FlavorId != 0)
            {
                _db.FlavorTreat.Add(new FlavorTreat()
                {
                    FlavorId = FlavorId, TreatId = treat.TreatId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public void CanBeConstructedWithList()
        {
            //Given
            List <Item> inv       = new List <Item>();
            Armor       testArmor = new Armor();
            Treat       testTreat = new Treat();

            inv.Add(testArmor);
            inv.Add(testTreat);
            Shop shop = new Shop("testShop", inv);

            //When
            int expected = 2;
            int actual   = shop.Inventory.Count;

            //Then
            Assert.True(expected == actual);
        }
Example #9
0
    public void StartTreat(int treatTag)
    {
        switch (treatTag)
        {
        case 0:
            CurrentTreat = TreatQuick;
            break;

        case 1:
            CurrentTreat = TreatMedium;
            break;

        case 2:
            CurrentTreat = TreatLong;
            break;
        }
        StartWorking();
    }
        public async Task <ActionResult> AddFlavor(Treat treat, int FlavorId)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            treat.User = currentUser;
            var thisFlavor = _db.Flavors.FirstOrDefault(flavor => flavor.FlavorId == FlavorId);

            if (FlavorId != 0)
            {
                _db.TreatFlavor.Add(new TreatFlavor()
                {
                    FlavorId = FlavorId, TreatId = treat.TreatId, TreatName = treat.Name, FlavorName = thisFlavor.Name
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #11
0
 public ActionResult Edit(Treat treat, int FlavorId, int joinId)
 {
     if (FlavorId != 0)
     {
         var joinEntry = _db.FlavorTreat.FirstOrDefault(entry => entry.FlavorTreatId == joinId);
         if (joinEntry != null)
         {
             _db.FlavorTreat.Remove(joinEntry);
         }
         _db.FlavorTreat.Add(new FlavorTreat()
         {
             FlavorId = FlavorId, TreatId = treat.TreatId
         });
     }
     _db.Entry(treat).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Treat treat, int FlavorId)
 {
     if (FlavorId != 0)
     {
         var joinTable = _db.FlavorTreat
                         .Any(join => join.TreatId == treat.TreatId && join.FlavorId == FlavorId);
         if (!joinTable)
         {
             _db.FlavorTreat.Add(new FlavorTreat()
             {
                 FlavorId = FlavorId, TreatId = treat.TreatId
             });
         }
     }
     _db.Entry(treat).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public async Task <IActionResult> Edit(Treat model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var response = await _lovePlatformApi.UpdateTreat(model);

            if (!response.IsSuccess)
            {
                ModelState.AddModelError("", response.Message);
                return(View(model));
            }
            // Delete treat image
            //var delResponse = _lovePlatformApi.DeleteTreatImage(model.Id);

            // Update treat image
            var files = Request.Form.Files;

            foreach (var file in files)
            {
                Byte[] fileData = new Byte[(int)file.Length];
                using (var memoryStream = new MemoryStream())
                {
                    await file.CopyToAsync(memoryStream);

                    fileData = memoryStream.ToArray();
                }

                // save image to OSS
                var r = await _lovePlatformApi.UploadImage(
                    new UploadImageInput { AvatarBuffer = fileData, Folder = "cure-record" });

                var fileName = r.ResultValue;

                await _lovePlatformApi.AddTreatImage(new TreatImage()
                {
                    ImagePath = fileName, TreatId = model.Id, UserId = model.UserId
                });
            }
            var user = await _lovePlatformApi.GetUser(model.UserId);

            return(RedirectToAction("Index", "User", new { openId = user.WexinOpenId }));
        }
Example #14
0
        public ActionResult IngredientSearch(string search)
        {
            List <Treat> model   = _db.Treats.ToList();
            Treat        match   = new Treat();
            List <Treat> matches = new List <Treat> {
            };

            if (!string.IsNullOrEmpty(search))
            {
                foreach (Treat Treat in model)
                {
                    if (Treat.Ingredients.ToLower().Contains(search))
                    {
                        matches.Add(Treat);
                    }
                }
            }
            return(View(matches));
        }
        public async Task <ActionResult> Edit(Treat treat)
        {
            if (treat.Name is null)
            {
                ViewBag.FlavorId     = new SelectList(_db.Flavors, "FlavorId", "Name");
                ViewBag.ErrorMessage = "Please enter the new treat's name";
                return(View(treat));
            }
            else
            {
                var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var currentUser = await _userManager.FindByIdAsync(userId);

                treat.User = currentUser;

                _db.Entry(treat).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Details", new { treatId = treat.TreatId }));
            }
        }
        public ActionResult AddFlavor(Treat treat, int FlavorId)
        {
            IQueryable <TreatFlavor> treatFlavors = _db.TreatFlavors.Where(entry => entry.TreatId == treat.TreatId);

            foreach (TreatFlavor entry in treatFlavors)
            {
                if (entry.FlavorId == FlavorId)
                {
                    return(RedirectToAction("Details", new { id = treat.TreatId }));
                }
            }
            if (FlavorId != 0)
            {
                _db.TreatFlavors.Add(new TreatFlavor()
                {
                    FlavorId = FlavorId, TreatId = treat.TreatId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Details", new { id = treat.TreatId }));
        }
Example #17
0
    private void GenerateNewTreat()
    {
        int   index = UnityEngine.Random.Range(0, m_possibleTreats.Count);
        IItem item;

        int roll = UnityEngine.Random.Range(0, 100);

        if (roll < m_detonatorPercent)
        {
            item = new Detonator();
        }
        else
        {
            item = new Treat();
            //Treat treat = new Treat();
        }

        item.Position = m_possibleTreats[index];
        m_treats.Add(item);
        m_possibleTreats.RemoveAt(index);
    }
Example #18
0
        public ActionResult Details(int id)
        {
            List <FlavourTreat> flavourTreats = new List <FlavourTreat>();

            flavourTreats = _db.FlavourTreat
                            .Include(flavourTreat => flavourTreat.Flavour)
                            .Where(flavourTreat => flavourTreat.TreatId == id)
                            .ToList();

            List <Flavour> flavours = new List <Flavour>();

            foreach (FlavourTreat flavourTreat in flavourTreats)
            {
                flavours.Add(flavourTreat.Flavour);
            }
            ViewBag.Flavours = flavours;
            Treat thistreat = _db.Treats
                              .Include(t => t.Flavours)
                              .FirstOrDefault(t => t.TreatId == id);

            return(View(thistreat));
        }
Example #19
0
 public void SetValues(Treat course)
 {
     if (CourseText)
     {
         CourseText.text = course.Name;
     }
     if (MoneyText)
     {
         MoneyText.text = course.Money.ToString();
     }
     if (IqText)
     {
         IqText.text = course.Heath.ToString();
     }
     if (HourText)
     {
         HourText.text = (course.Hours - course.PrecessedHours).ToString();
     }
     if (TimeText)
     {
         TimeText.text = "";                  // course.Working.WorkString;
     }
 }
Example #20
0
    private void ConsumeTreat()
    {
        IItem item = m_treats.Find(p => p.Position.x == m_player.Position.x && p.Position.y == m_player.Position.y);

        if (item != null)
        {
            if (item is Treat)
            {
                Treat treat = (Treat)item;
                m_effectSource.clip = m_carrotEffect;
                //m_effectSource.volume = 0.15f;
                m_effectSource.Play();
                m_score += treat.Value;
            }
            else if (item is Detonator)
            {
                m_hunter.DetonateMines();
                m_effectSource.clip = m_explosionEffect;
                m_effectSource.Play();
            }
            RecycleTreat(item);
        }
    }
Example #21
0
 public ActionResult AddFlavor(Treat treat, int FlavorId)
 {
     if (FlavorId != 0)
     {
         var comparetreatflavor = _db.FlavorTreat.FirstOrDefault(flavor => flavor.FlavorId == FlavorId);
         foreach (FlavorTreat compareFlavor in treat.Flavors)
         {
             if (treat.TreatId == comparetreatflavor.TreatId)
             {
                 if (comparetreatflavor.FlavorId == FlavorId)
                 {
                     return(RedirectToAction("Index", "Treats"));
                 }
             }
         }
         _db.FlavorTreat.Add(new FlavorTreat()
         {
             FlavorId = FlavorId, TreatId = treat.TreatId
         });
         _db.SaveChanges();
     }
     return(RedirectToAction("Index", "Treats"));
 }
Example #22
0
        public async Task <ActionResult> Create(FlavorTreat newTreat, int FlavorID)
        {
            Treat foundTreat = _db.Treats.Where(t => t.TreatName == newTreat.Treat.TreatName).FirstOrDefault();

            Console.WriteLine(foundTreat.TreatName);
            if (foundTreat != null)
            {
                newTreat.Treat.TreatID = foundTreat.TreatID;
            }
            else
            {
                var userID      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var currentUser = await _userManager.FindByIdAsync(userID);

                newTreat.Treat.CreatedBy = currentUser;
            }
            Flavor foundFlavor = _db.Flavors.FirstOrDefault(t => t.FlavorID == FlavorID);

            newTreat.Flavor = foundFlavor;
            _db.FlavorTreats.Add(newTreat);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #23
0
        public void ShowEventDetails()
        {
            Burger  burger          = _eventRepo.GetBurgerBooth();
            Treat   treat           = _eventRepo.GetTreatBooth();
            decimal totalBurgerCost = burger.HamCost * burger.HamCount + burger.HotdogCost * burger.HotdogCount + burger.VegCost * burger.VegCount + burger.MiscCost;
            decimal totalTreatCost  = treat.IceCreamCost * treat.IceCreamCount + treat.PopcornCost * treat.PopcornCount + treat.MiscCost;

            Console.WriteLine($"Burger Booth Information" +
                              $"\nHamburger total cost: ${burger.HamCost * burger.HamCount}" +
                              $"\nVeggie burger total cost: ${burger.VegCost * burger.VegCount}" +
                              $"\nHotdog total cost: ${burger.HotdogCost * burger.HotdogCount}" +
                              $"\nMiscellaneous costs: ${burger.MiscCost}" +
                              $"\nTotal number of tickets used at this booth: {burger.HamCount +burger.HotdogCount + burger.VegCount} tickets" +
                              $"\n\nTreat Booth Information" +
                              $"\nIce Cream total cost: ${treat.IceCreamCost * treat.IceCreamCount}" +
                              $"\nPopcorn total cost: ${treat.PopcornCost*treat.PopcornCount}" +
                              $"\nMiscellaneous costs: ${treat.MiscCost}" +
                              $"\nTotal number of tickets used at this booth: {treat.IceCreamCount + treat.PopcornCount} tickets" +
                              $"\n\nTotal Cost of Event: ${totalBurgerCost+totalTreatCost}" +
                              $"\nTotal number of tickets used at any booth: {treat.IceCreamCount +treat.PopcornCount+ burger.HamCount + burger.HotdogCount + burger.VegCount} tickets");
            Console.Write("Press any key to continue");
            Console.ReadKey();
        }
        public async Task <IActionResult> EditTreat(Treat treat)
        {
            if (!ModelState.IsValid)
            {
                return(View(treat));
            }
            await _treatService.Update(treat);

            //上传文件
            var files = Request.Form.Files;

            foreach (var file in files)
            {
                //转换成二进制
                Byte[] fileData = new Byte[(int)file.Length];
                using (var memoryStream = new MemoryStream())
                {
                    await file.CopyToAsync(memoryStream);

                    fileData = memoryStream.ToArray();
                }

                //保存图片到服务器
                var r = await _lovePlatformApi.UploadImage(
                    new UploadImageInput { AvatarBuffer = fileData, Folder = "cure-record" });

                var fileName = r.ResultValue;

                _treatImageService.Add(new TreatImage()
                {
                    ImagePath = fileName, TreatId = treat.Id, UserId = treat.UserId
                });
            }

            return(RedirectToAction("Detail", "User", new { id = treat.UserId }));
        }
Example #25
0
        public async Task <ActionResult> AddFlavor(int TreatID, int flavorID)
        {
            // Treat foundTreat = _db.Treats.FirstOrDefault(t => t.TreatID == TreatID);
            Flavor      foundFlavor    = _db.Flavors.FirstOrDefault(t => t.FlavorID == flavorID);
            Treat       foundTreat     = _db.Treats.Where(t => t.TreatID == TreatID).FirstOrDefault();
            FlavorTreat newFlavorTreat = new FlavorTreat();

            // conditional isnt really needed it should be able to find a treat
            if (foundTreat != null)
            {
                newFlavorTreat.Treat = foundTreat;
            }
            else
            {
                var userID      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var currentUser = await _userManager.FindByIdAsync(userID);
            }

            newFlavorTreat.Flavor = foundFlavor;
            newFlavorTreat.Treat  = foundTreat;
            _db.FlavorTreats.Add(newFlavorTreat);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #26
0
        // Details **************
        public ActionResult Details(int id)
        {
            Treat model = _db.Treats.FirstOrDefault(treat => treat.TreatId == id);

            return(View(model));
        }
Example #27
0
 public ActionResult Edit(Treat treat)
 {
     _db.Entry(treat).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #28
0
 public ActionResult Create(Treat treat)
 {
     _db.Treats.Add(treat);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Treat treat)
 {
     _db.Entry(treat).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Details", new { id = treat.TreatId }));
 }
        public ActionResult Edit(int id)
        {
            Treat treat = _db.Treats.FirstOrDefault(x => x.Id == id);

            return(View(treat));
        }
Example #31
0
        public async Task <IActionResult> Delete(int id)
        {
            Treat thisTreat = await _db.Treats.SingleOrDefaultAsync(treats => treats.TreatId == id);

            return(View(thisTreat));
        }
Example #32
0
        public ActionResult Delete(int id)
        {
            Treat thisTreat = _db.Treats.FirstOrDefault(treat => treat.TreatId == id);

            return(View(thisTreat));
        }
Example #33
0
    public override void StartWorking()
    {
        if (!GameManager.AddMoney(-CurrentTreat.Money))
            {
                CurrentTreat = null;
                return;
            }

        GameManager.PlayerStatus = PlayerStatus.HEALING;
        GUImain.ShowDialog(DialogKind.WORKING);
        GameManager.Continue(1f);
    }
Example #34
0
 public override void StopWorking()
 {
     CurrentTreat = null;
     GameManager.PlayerStatus = PlayerStatus.NONE;
     GameManager.GamePaused = true;
     GUImain.CloseAllDialogs();
 }