Exemplo n.º 1
0
        public override void Upsert(int index, CubeViewModel data)
        {
            base.Upsert(index, data);

            var cubeData = XmlKey.CubeData.Find <CubeDataXml.Data>(x => x.CubeId == data.CubeId);
            var price    = ServerDefine.CubeLv2Price((byte)data?.Lv);
            var AD       = ServerDefine.CubeLv2AD(cubeData.AD, data.Lv);
            var AS       = ServerDefine.CubeLv2AS(cubeData.AS, data.Lv);

            cube_image.color = new Color(cubeData.Color[0], cubeData.Color[1], cubeData.Color[2]);
            lv_text?.SetText(data?.Lv.ToString());
            ad_text?.SetText(AD.ToString("N2"));
            as_text?.SetText(AS.ToString("N2"));
            price_text?.SetText(price.ToString());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateLv(string userId, int cubeId)
        {
            try
            {
                var user = await _unitOfWork.Users.GetAsync(x => x.Id == userId, isTracking : true);

                if (user == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                var lv   = 0;
                var cube = await _unitOfWork.Cubes.GetAsync(x => x.UserId == userId && x.CubeId == cubeId);

                if (cube != null)
                {
                    lv = cube.Lv;
                }

                var price = ServerDefine.CubeLv2Price((byte)lv);

                if (user.Money < price)
                {
                    return(Payloader.Fail(PayloadCode.Not));
                }

                user.Money -= price;

                var newCube = await _unitOfWork.Cubes.UpdateLv(userId, cubeId, 1);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(new UpdateCubeLvBody()
                {
                    Cube = _mapper.Map <CubeViewModel>(newCube),
                    Money = user.Money,
                }));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
Exemplo n.º 3
0
 protected override bool IsLock()
 {
     return(ServerInfo.User.Money < ServerDefine.CubeLv2Price(props.data.Lv));
 }