Пример #1
0
    public void Update(GamepadState first, GamepadState second, GamepadState third, GamepadState fourth)
    {
        Connected = first.Connected || second.Connected || third.Connected || fourth.Connected;
        if (!Connected)
        {
            return;
        }

        // Shoulders
        LeftShoulder  = ArrayHelper.Coalesce(first.LeftShoulder, second.LeftShoulder, third.LeftShoulder, fourth.LeftShoulder);
        RightShoulder = ArrayHelper.Coalesce(first.RightShoulder, second.RightShoulder, third.RightShoulder, fourth.RightShoulder);

        // Triggers
        LeftTrigger  = ArrayHelper.Coalesce(first.LeftTrigger, second.LeftTrigger, third.LeftTrigger, fourth.LeftTrigger);
        RightTrigger = ArrayHelper.Coalesce(first.RightTrigger, second.RightTrigger, third.RightTrigger, fourth.RightTrigger);

        // Buttons
        Start = ArrayHelper.Coalesce(ComplexButtonStateComparer.Default, first.Start, second.Start, third.Start, fourth.Start);
        Back  = ArrayHelper.Coalesce(ComplexButtonStateComparer.Default, first.Back, second.Back, third.Back, fourth.Back);

        A = ArrayHelper.Coalesce(first.A, second.A, third.A, fourth.A);
        B = ArrayHelper.Coalesce(first.B, second.B, third.B, fourth.B);
        X = ArrayHelper.Coalesce(first.X, second.X, third.X, fourth.X);
        Y = ArrayHelper.Coalesce(first.Y, second.Y, third.Y, fourth.Y);

        // D-Pad
        DPad = ArrayHelper.Coalesce(first.DPad, second.DPad, third.DPad, fourth.DPad);

        // Thumbsticks
        LeftStick  = ArrayHelper.Coalesce(first.LeftStick, second.LeftStick, third.LeftStick, fourth.LeftStick);
        RightStick = ArrayHelper.Coalesce(first.RightStick, second.RightStick, third.RightStick, fourth.RightStick);
    }
Пример #2
0
        public async Task <IActionResult> Create(ProductViewModel model, string returnUrl = null)
        {
            ReturnUrl = returnUrl;

            if (ModelState.IsValid)
            {
                if (await Uow.Products.Where(p => p.ProductNumber == model.ProductNumber).AnyAsync())
                {
                    ModelState.AddModelError(nameof(ProductViewModel.ProductNumber), ValidationResources.DuplicatedValidationError);
                }

                if (await Uow.Products.Where(p => p.Name == model.Name).AnyAsync())
                {
                    ModelState.AddModelError(nameof(ProductViewModel.Name), ValidationResources.DuplicatedValidationError);
                }
            }

            if (!ModelState.IsValid)
            {
                BindControls(model);
                Title     = ProductResources.ProductNumber;
                ReturnUrl = returnUrl;
                return(View(model));
            }



            var product = new Product
            {
                Name          = model.Name,
                ProductNumber = model.ProductNumber,
                CategoryId    = ArrayHelper.Coalesce(model.SubCategoryId, model.CategoryId),
                CurrencyId    = ISO4217.GEL.ToInt32(),
                CreatorId     = UserId
            };

            Uow.Products.Add(product);
            await Uow.SaveAsync();

            return(!string.IsNullOrEmpty(returnUrl)
                ? RedirectToLocal(returnUrl)
                : RedirectToAction(nameof(Index)));
        }