Exemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            ViewBag.BasketCount = 0;
            ViewBag.Fullname    = "";
            if (User.Identity.IsAuthenticated)
            {
                AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);

                ViewBag.Fullname = user.Fullname;
            }

            if (Request.Cookies["basket"] != null)
            {
                List <BasketVM> products     = JsonConvert.DeserializeObject <List <BasketVM> >(Request.Cookies["basket"]);
                List <BasketVM> userProdcuts = new List <BasketVM>();
                foreach (var item in products)
                {
                    if (item.Username == User.Identity.Name)
                    {
                        userProdcuts.Add(item);
                    }
                }

                ViewBag.BasketCount = userProdcuts.Count;
            }
            Bio model = _db.Bios.FirstOrDefault();

            return(View(await Task.FromResult(model)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            AboutWelcome          aboutWelcome = _db.AboutWelcomes.FirstOrDefault();
            ICollection <Teacher> teachers     = await _db.Teachers.Include(t => t.TeacherContact).Take(4).ToListAsync();

            AboutSlider aboutSlider = await _db.AboutSliders.FirstOrDefaultAsync();

            AboutVideo aboutVideo = await _db.AboutVideos.FirstOrDefaultAsync();

            ICollection <AboutNotice> aboutNotices = await _db.AboutNotices.Take(6).ToListAsync();

            Bio bio = await _db.Bios.FirstOrDefaultAsync();

            AboutVM aboutVM = new AboutVM()
            {
                AboutWelcome = aboutWelcome,
                Teachers     = teachers,
                Bio          = bio,
                AboutSlider  = aboutSlider,
                AboutVideo   = aboutVideo,
                AboutNotices = aboutNotices
            };

            return(View(aboutVM));
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            List <Book>     books      = _db.Books.Include(b => b.Publisher).ToList();
            Book            book       = _db.Books.Include(b => b.Publisher).Include(b => b.BookAuthors).ThenInclude(ba => ba.Author).Include(b => b.BookCategories).ThenInclude(b => b.Category).OrderByDescending(b => b.SaleCount).FirstOrDefault();
            List <Category> categories = _db.Categories.OrderBy(n => n.Name).ToList();
            Bio             bio        = _db.Bios.FirstOrDefault();

            ViewBag.Currency = bio.Currency;

            List <BookCategory> rBookCategories = new List <BookCategory>();

            foreach (BookCategory bookCategory in book.BookCategories)
            {
                List <BookCategory> NewrBookCategories = _db.BookCategories.Include(bc => bc.Category).Include(bc => bc.Book).OrderByDescending(nrbc => nrbc.Id).Where(bc => bc.CategoryId == bookCategory.CategoryId).ToList();
                foreach (BookCategory newR in NewrBookCategories)
                {
                    if (rBookCategories.FirstOrDefault(bc => bc.BookId == newR.BookId) == null && newR.BookId != book.Id)
                    {
                        rBookCategories.Add(newR);
                    }
                }
            }
            NewBooksVM model = new NewBooksVM
            {
                Books           = books,
                Book            = book,
                Categories      = categories,
                rBookCategories = rBookCategories,
                Bio             = bio
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Update(int?id, Bio Bio)
        {
            Bio viewBio = _db.Bios.FirstOrDefault(c => c.Id == id && c.IsDeleted == false);

            if (Bio.Photo != null)
            {
                if (!Bio.Photo.IsImage())
                {
                    ModelState.AddModelError("", "Bunu yaratmaq ucun wekil tipi yarat!!!");
                    return(View(viewBio));
                }
                if (!Bio.Photo.MaxSize(200))
                {
                    ModelState.AddModelError("", "Wekilin olcusu 200kb-dan az olmalidi!!!");
                    return(View(viewBio));
                }

                string folder   = Path.Combine("img");
                string fileName = await Bio.Photo.SaveImgAsync(_env.WebRootPath, folder);

                Bio.LogoImage = fileName;
            }

            Bio.IsDeleted       = false;
            viewBio.Title       = Bio.Title;
            viewBio.Description = Bio.Description;
            viewBio.Address     = Bio.Address;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        private void CreateTestCase_Split(int streamLength, int partLength)
        {
            var expectedPartCount = (int)Math.Ceiling((decimal)streamLength / partLength);

            using (var stream = Bio.RandomStream(streamLength)) {
                var i = 0;
                foreach (var part in stream.Split(partLength))
                {
                    i++;

                    var expected = partLength;
                    if (i == expectedPartCount)
                    {
                        var rest = streamLength % partLength;
                        if (rest > 0)
                        {
                            expected = rest;
                        }
                    }

                    Assert.AreEqual(expected, part.Length);
                }

                Assert.AreEqual(expectedPartCount, i);
            }
        }
Exemplo n.º 6
0
        public void HexToBytes_EmptyString()
        {
            var result = Bio.HexToBytes("");

            Assert.AreEqual(0, result.Length);
            Assert.IsTrue(new byte[0].SequenceEqual(result));
        }
Exemplo n.º 7
0
        static int GetInstallerVersion(Stream decompressedStream, BinaryReader binaryReader, ushort fileNumber,
                                       long dataStreamLength)
        {
            if (installerVersion > -1)
            {
                return(installerVersion);
            }

            if (TestInstallerVersion("40", TryParse40, decompressedStream, binaryReader, fileNumber, dataStreamLength))
            {
                return(40);
            }
            if (TestInstallerVersion("35", TryParse35, decompressedStream, binaryReader, fileNumber, dataStreamLength))
            {
                return(35);
            }
            if (TestInstallerVersion("30", TryParse30, decompressedStream, binaryReader, fileNumber, dataStreamLength))
            {
                return(30);
            }
            if (TestInstallerVersion("20", TryParse20, decompressedStream, binaryReader, fileNumber, dataStreamLength))
            {
                return(20);
            }

            Bio.Error($"Failed to determine installer version. Please send a bug report if you want the file to be supported in a future version.", Bio.EXITCODE.NOT_SUPPORTED);
            return(-1);
        }
Exemplo n.º 8
0
 protected override void DamageInternal(Buff buff, Bio target, float damage)
 {
     if (++this._count == ( int )this.extra[0])
     {
         this.owner.DestroyBuffState(this);
     }
 }
Exemplo n.º 9
0
        public bool CreateBio(BioCreate model)
        {
            var entity =
                new Bio()
            {
                OwnerId   = _userId,
                FullName  = model.FullName,
                NickNames = model.NickNames,
                Birthday  = model.Birthday,
                Age       = model.Age,
                Gender    = model.Gender,
                Location  = model.Location,
                Race      = model.Race,
                Ethnicity = model.Ethnicity,
                AboutYou  = model.AboutYou,
                Interests = model.Interests,
                Hobbies   = model.Hobbies,

                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Bios.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 10
0
 protected override void OnExit()
 {
     this.owner.steering.Off(SteeringBehaviors.BehaviorType.Pursuit);
     this.owner.steering.Off(SteeringBehaviors.BehaviorType.Seek);
     this._target             = null;
     this._moveCompleteHander = null;
 }
Exemplo n.º 11
0
        static bool TestInstallerVersion(string version, Func <Stream, BinaryReader, FileInfo> parsingFunction, Stream decompressedStream, BinaryReader binaryReader, int fileNumber, long dataStreamLength)
        {
            Bio.Debug($"\nTesting installer version {version}\n");
            var pos = decompressedStream.Position;

            for (var i = 0; i < fileNumber; i++)
            {
                try {
                    var fileInfo = parsingFunction(decompressedStream, binaryReader);

                    Bio.Debug(string.Format("Node {0} at offset {1}, size: {2}, end: {3}", i, fileInfo.nodeStart, fileInfo.nodeSize, fileInfo.nodeEnd));

                    if (!fileInfo.IsValid(dataStreamLength))
                    {
                        Bio.Debug(fileInfo);
                        Bio.Debug("Invalid file info");
                        decompressedStream.Position = pos;
                        return(false);
                    }

                    if (fileInfo.type != 0)
                    {
                        decompressedStream.Position = fileInfo.nodeEnd;
                    }
                }
                catch (EndOfStreamException) {
                    Bio.Debug("End of Stream reached while parsing file list");
                    decompressedStream.Position = pos;
                    return(false);
                }
            }

            decompressedStream.Position = pos;
            return(true);
        }
Exemplo n.º 12
0
        protected override void DamageInternal(Buff buff, Bio target, float damage)
        {
            if (buff.skillData.isCommon)
            {
                return;
            }

            int charge;

            if (!this._chargesPreSkill.TryGetValue(buff.skillData.id, out charge))
            {
                this._chargesPreSkill[buff.skillData.id] = 0;
                charge = 0;
            }
            int maxChargePreSkill = ( int )this.extra[0];

            if (charge < maxChargePreSkill)
            {
                ++this._totalCharges;
                ++charge;
                this._chargesPreSkill[buff.skillData.id] = charge > maxChargePreSkill ? maxChargePreSkill : charge;
            }

            if (this._totalCharges > ( int )this.extra[1])
            {
                this.owner.property.Add(Attr.Hp, damage * this.extra[2]);
                this._totalCharges = 0;
                this._chargesPreSkill.Clear();
            }
        }
Exemplo n.º 13
0
        protected virtual float CalcDamageInternal(Bio caster, Bio target, int index)
        {
            BuffData.Trigger trigger        = this._buff.trigger;
            EntityProperty   casterProperty = caster.property;
            EntityProperty   targetProperty = target.property;
            float            cad            = casterProperty.ad;
            float            cap            = casterProperty.ap;
            float            std            = trigger.td?[index] ?? 0f;
            float            sad            = trigger.ad?[index] ?? 0f;
            float            sap            = trigger.ap?[index] ?? 0f;
            float            tpadp          = trigger.tpadp?[index] ?? 0f;
            float            tpapp          = trigger.tpapp?[index] ?? 0f;
            float            padp           = trigger.padp?[index] ?? 0f;
            float            papp           = trigger.papp?[index] ?? 0f;

            float armorResist = MathUtils.Max(0, targetProperty.armor * (1 - casterProperty.armorPen) - casterProperty.armorPenFlat);
            float tad         = sad + cad * padp;
            float pdamage     = tad * (100 / (100 + armorResist));

            float magicResist = MathUtils.Max(0, targetProperty.magicResist * (1 - casterProperty.magicPen) - casterProperty.magicPenFlat);
            float tap         = sap + cap * papp;
            float mdamage     = tap * (100 / (100 + magicResist));

            float trueDamage = std + cad * tpadp + cap * tpapp;

            return(pdamage + mdamage + trueDamage);
        }
Exemplo n.º 14
0
        public int AddBioToTrad([FromBody] Bio bio)
        {
            int result;

            try
            {
                if (bio.text.Length < 25 || bio.text.Length > 150)
                {
                    result = 0;
                }
                else
                {
                    result = objtraduct.AddBio(bio.idTraductor, bio.text);
                }
            }
            catch (NullReferenceException nullEx)
            {
                throw nullEx;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Exemplo n.º 15
0
 private void HandleTargetInOut(List <Bio> targetsEnter, List <Bio> targetsExit)
 {
     if (targetsEnter != null)
     {
         int c1 = targetsEnter.Count;
         for (int i = 0; i < c1; i++)
         {
             Bio target = targetsEnter[i];
             this.OnTargetEnter(target);
             LLogger.Info("enter");
             target.AddRef();
         }
     }
     if (targetsExit != null)
     {
         int count = targetsExit.Count;
         for (int i = 0; i < count; i++)
         {
             Bio target = targetsExit[i];
             LLogger.Info("exit");
             this.OnTargetExit(target);
             target.RedRef();
         }
     }
 }
Exemplo n.º 16
0
        private void CalcDamage(Bio caster, Bio target, int triggerIndex)
        {
            BuffData.Trigger trigger = this._buff.trigger;
            if (trigger.damaged == null)
            {
                return;
            }

            int index = trigger.damaged.Length - 1;

            index = triggerIndex <= index ? triggerIndex : index;

            if (!trigger.damaged[index])
            {
                return;
            }

            float damage = this.CalcDamageInternal(caster, target, index);

            target.property.Add(Attr.Hp, -damage);

            if (target.property.hp <= 0)
            {
                target.sensorySystem.killer = caster;
            }

            SyncEventHelper.Damage(this._buff.rid, damage, caster.rid, target.rid);
            this.OnDamage(damage, caster, target, triggerIndex);
            caster.OnDamage(this._buff, target, damage);
            target.OnHurt(this._buff, caster, damage);
        }
Exemplo n.º 17
0
        public Buff CreateBuff(string buffId, string skillId, int lvl, Bio caster, Bio target, Vec3 targetPoint)
        {
            string bid  = this._random.IdHash(buffId);
            Buff   buff = this._buffManager.Create(bid, skillId, lvl, caster, target, targetPoint);

            return(buff);
        }
Exemplo n.º 18
0
        protected override float CalcDamageInternal(Bio caster, Bio target, int index)
        {
            BuffData.Trigger trigger = this._buff.trigger;
            float            cad     = caster.property.ad;
            float            cap     = caster.property.ap;

            if (!this._reverted)
            {
                float sad  = trigger.ad?[index] ?? 0f;
                float sap  = trigger.ap?[index] ?? 0f;
                float padp = trigger.padp?[index] ?? 0f;
                float papp = trigger.papp?[index] ?? 0f;

                float armorResist = MathUtils.Max(0, target.property.armor * (1 - caster.property.armorPen) - caster.property.armorPenFlat);
                float tad         = sad + cad * padp;
                float pdamage     = tad * (100 / (100 + armorResist));

                float magicResist = MathUtils.Max(0, target.property.magicResist * (1 - caster.property.magicPen) - caster.property.magicPenFlat);
                float tap         = sap + cap * papp;
                float mdamage     = tap * (100 / (100 + magicResist));

                return(pdamage + mdamage);
            }
            float std   = trigger.td?[index] ?? 0f;
            float tpadp = trigger.tpadp?[index] ?? 0f;
            float tpapp = trigger.tpapp?[index] ?? 0f;

            return(std + cad * tpadp + cap * tpapp);
        }
        public ActionResult <BioReturnDto> Get()
        {
            Bio bio       = _context.Bios.FirstOrDefault();
            var mapperBio = _mapper.Map <Bio, BioReturnDto>(bio);

            return(Ok(mapperBio));
        }
        public async Task <ActionResult <Bio> > Update(int id, [FromForm] BioUpdateDto bioUpdateDto)
        {
            if (id != bioUpdateDto.Id)
            {
                return(BadRequest());
            }
            Bio dbBio = _context.Bios.FirstOrDefault(p => p.Id == id);

            if (dbBio == null)
            {
                return(NotFound());
            }
            dbBio.Phone    = bioUpdateDto.Phone;
            dbBio.Email    = bioUpdateDto.Email;
            dbBio.Facebook = bioUpdateDto.Facebook;
            dbBio.Address  = bioUpdateDto.Address;

            string folderName = Path.Combine("images", "logo");

            if (bioUpdateDto.Logo != null)
            {
                ImageExtension.DeleteImage(_env.WebRootPath, folderName, dbBio.LogoUrl);
                string fileName = await bioUpdateDto.Logo.SaveImg(_env.WebRootPath, folderName);

                dbBio.LogoUrl = fileName;
            }
            await _context.SaveChangesAsync();

            return(Ok(dbBio));
        }
Exemplo n.º 21
0
        protected override void OnTargetTrigger(Bio target, int triggerIndex)
        {
            base.OnTargetTrigger(target, triggerIndex);

            EntityUtils.GetEntitiesInCircle(this._buff.battle.GetEntities(), this._buff.property.position,
                                            this._buff.radius, ref this._temp1);
            EntityUtils.FilterTarget(this._buff.caster, CampType.Hostile | CampType.Neutral, EntityFlag.Hero, ref this._temp1,
                                     ref this._temp2);

            if (this._temp2.Count > 0)
            {
                int index = this._buff.battle.random.Next(0, this._temp2.Count);                  //上限是闭区间
                this.CreateMissile(( Bio )this._temp2[index]);
            }
            else
            {
                this._temp2.Clear();
                EntityUtils.FilterTarget(this._buff.caster, CampType.Hostile, EntityFlag.SmallPotato, ref this._temp1,
                                         ref this._temp2);
                if (this._temp2.Count > 0)
                {
                    int index = this._buff.battle.random.Next(0, this._temp2.Count);
                    this.CreateMissile(( Bio )this._temp2[index]);
                }
            }
            this._temp1.Clear();
            this._temp2.Clear();
        }
Exemplo n.º 22
0
        static FileInfo TryParse40(Stream decompressedStream, BinaryReader binaryReader)
        {
            var fileInfo = new FileInfo(decompressedStream.Position, binaryReader.ReadUInt32(), binaryReader.ReadUInt16());

            if (fileInfo.type != 0)
            {
                return(fileInfo);
            }

            decompressedStream.Skip(3);
            // Empty dummy files are missing file time attributes,
            // so the node is shorter than usual
            if (binaryReader.ReadByte() == 0xE2)
            {
                decompressedStream.Skip(30);
            }
            else
            {
                decompressedStream.Skip(14);
                var uncompressedSize = binaryReader.ReadUInt32();
                var offset           = binaryReader.ReadUInt32();
                var compressedSize   = binaryReader.ReadUInt32();
                decompressedStream.Skip(4);
                fileInfo.SetFileInfos(offset, compressedSize, 0, uncompressedSize);
                fileInfo.SetFileTimes(binaryReader.ReadInt64(), binaryReader.ReadInt64(), binaryReader.ReadInt64());
            }

            ReadFilePath(decompressedStream, binaryReader, fileInfo);
            Bio.Debug(fileInfo);
            return(fileInfo);
        }
Exemplo n.º 23
0
        public ActionResult saveBio(int?id, Bio exx)
        {
            Bio entity = db.Bio.Find(id);

            if (entity == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (Request.IsAjaxRequest())
            {
                if (ModelState.IsValid)
                {
                    entity.Description      = exx.Description;
                    entity.SkillLevel       = exx.SkillLevel;
                    entity.SkillDescription = exx.SkillDescription;
                    entity.IsBar            = exx.IsBar;
                    entity.IsTag            = exx.IsTag;
                    entity.SkillId          = exx.SkillId;
                    entity.CategoryId       = exx.CategoryId;
                    entity.ModifiedDate     = DateTime.UtcNow;
                    db.Entry(entity).State  = EntityState.Modified;
                    db.SaveChanges();
                    var bios = db.Bio.Where(w => w.DeletedDate == null).ToList();
                    return(PartialView("~/Areas/Admin/Views/Dashboard/partial/_PartialBioList.cshtml", bios));
                }
            }
            return(View());
        }
Exemplo n.º 24
0
        public override float CalculateDesirability()
        {
            Bio self = ( Bio )this.brain.owner;
            //todo 使用技能的策略?
            Skill skill = self.commonSkill;

            if (!self.CanUseSkill(skill))
            {
                return(0);
            }

            if (this._lastTarget != null)
            {
                if (this._lastTarget.isDead || !self.WithinSkillRange(this._lastTarget, skill))
                {
                    this._lastTarget = null;
                }
                this._target = this._lastTarget;
            }
            else
            {
                this._target     = EntityUtils.GetNearestTarget(self.battle.GetEntities(), self, self.fov, skill.campType, skill.targetFlag);
                this._lastTarget = this._target;
            }
            return(this._target == null ? 0 : 1);
        }
Exemplo n.º 25
0
        public IActionResult Index()
        {
            Bio bio = _db.Bios.FirstOrDefault();

            ViewBag.Bio = bio;
            return(View(_db.Bios.FirstOrDefault()));
        }
Exemplo n.º 26
0
        protected override void Activate()
        {
            this._status = Status.Active;

            Bio bio = ( Bio )this.owner;

            bio.Attack(bio.commonSkill, this._target, Vec3.zero);
        }
Exemplo n.º 27
0
        public Bio CreateBio(EntityParam param)
        {
            Bio entity = this.CreateEntity <Bio>(param);

            this._idToBio[param.rid] = entity;
            this._bios.Add(entity);
            return(entity);
        }
Exemplo n.º 28
0
        public void PathReplaceInvalidChars_InvalidChars()
        {
            Assert.AreEqual(ABSOLUTE_FILE, Bio.PathReplaceInvalidChars(INVALID_PATH, ""));

            var expected = INVALID_PATH.Replace("<", "_").Replace(">", "_");

            Assert.AreEqual(expected, Bio.PathReplaceInvalidChars(INVALID_PATH));
        }
Exemplo n.º 29
0
        public override void SetGoal()
        {
            GoalAttack goalAttack = this.brain.PopGoal <GoalAttack>();

            goalAttack.SetTarget(this._target);
            this.brain.AddSubgoal(goalAttack);
            this._target = null;
        }
Exemplo n.º 30
0
        protected override void OnExit()
        {
            this.owner.steering.Off(SteeringBehaviors.BehaviorType.FollowPath);
            this.owner.steering.Off(SteeringBehaviors.BehaviorType.ObstacleAvoidance);

            this._target.RedRef();
            this._target = null;
        }