Esempio n. 1
0
        public ActionResult AddUserBuilding(UserBuildingsViewModel userBuildingModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            UserBuildingDto _userBuildingDto = new UserBuildingDto();

            _userBuildingDto.User_ID = userBuildingModel.viewModel.User_ID;
            _userBuildingDto.Login = userBuildingModel.viewModel.User_Login;
            _userBuildingDto.X_pos = userBuildingModel.viewModel.X_pos;
            _userBuildingDto.Y_pos = userBuildingModel.viewModel.Y_pos;
            _userBuildingDto.Lvl = userBuildingModel.viewModel.Lvl;
            _userBuildingDto.Building_ID = userBuildingModel.viewModel.Building_ID;
            _userBuildingDto.Building_Name = userBuildingModel.viewModel.Building_Name;
            _userBuildingDto.Status = userBuildingModel.viewModel.Status;
            _userBuildingDto.Owner = userBuildingModel.viewModel.Owner.ToLower().Contains("tak") ? true : false;
            _userBuildingDto.Percent_Product = userBuildingModel.viewModel.Percent_product;
            _userBuildingDto.Color = userBuildingModel.viewModel.Color;

            if (_userBuildingService.Add(_userBuildingDto))
            {
                errors.Add("Dodano budynek użytkownikowi.");
            }
            else
            {
                errors.Add("Błąd. Spróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }
Esempio n. 2
0
        public ActionResult _UserBuildingList()
        {
            UserBuildingsViewModel userBuildingModel = new UserBuildingsViewModel();
            userBuildingModel.listModel = new List<ItemUserBuildingViewModel>();

            foreach (var item in _userBuildingService.GetUserBuildingList(User.Identity.Name))
            {
                var building = _buildingsHelper.GetBuildings().Where(b => b.ID == item.Building_ID).First();
                int bTime = 0;
                int timeLeft = 0;
                string status = String.Empty;
                if (item.Status == "budowa" || item.Status == "rozbudowa")
                {
                    bTime = building.BuildingTime;
                    timeLeft = _buildingsHelper.BuildingTimeLeft(User.Identity.Name, item.ID);
                }
                else if (item.Status == "burzenie")
                {
                    bTime = building.DestructionTime;
                    timeLeft = _buildingsHelper.BuildingTimeLeft(User.Identity.Name, item.ID);
                }
                userBuildingModel.listModel.Add(new ItemUserBuildingViewModel
                {
                    ID = item.ID,
                    User_ID = item.User_ID,
                    User_Login = item.Login,
                    X_pos = item.X_pos,
                    Y_pos = item.Y_pos,
                    Lvl = item.Lvl,
                    Building_ID = item.Building_ID,
                    Building_Name = item.Building_Name,
                    Status = item.Status,
                    Produkcja = item.Produkcja,
                    ifCan = _userBuildingService.ifLvlUp(item.ID, User.Identity.Name),
                    Percent_price_per_lvl = item.PriceLvlUp,
                    Percent_product_per_lvl = item.ProdukcjaLvlUp,
                    Color = item.Color,
                    Stock = item.Stock,
                    BuildTime = bTime,
                    BuildDone = bTime - timeLeft,
                    ifDeal = (item.DealID != null) ? "Tak" : "Nie"
                });
            }

            return View(userBuildingModel);
        }
Esempio n. 3
0
        public ActionResult _UserBuildingList()
        {
            UserBuildingsViewModel userBuildingModel = new UserBuildingsViewModel();
            userBuildingModel.listModel = _userBuildingService.GetUserBuilding().Select(x => new ItemUserBuildingViewModel
            {
                ID = x.ID,
                User_ID = x.User_ID,
                User_Login = x.Login,
                X_pos = x.X_pos,
                Y_pos = x.Y_pos,
                Lvl = x.Lvl,
                Building_ID = x.Building_ID,
                Building_Name = x.Building_Name,
                Status = x.Status,
                DateOfConstruction = x.DateOfConstruction,
                Color = x.Color,
                Percent_product = x.Percent_Product,
                Owner = x.Owner ? "Tak" : "Nie",
                ifDeal = x.DealID!=null ? "Tak" : "Nie"
            }).ToList();

            userBuildingModel.allBuilding = _buildingService.GetBuilding().Select(x => x.Alias).ToArray();
            userBuildingModel.allProduct = _productService.GetProduct().Select(x => x.Alias).ToArray();
            userBuildingModel.allUser = _userService.GetUser().Select(x => x.Login).ToArray();

            return View(userBuildingModel);
        }