예제 #1
0
        public ActionResult AddDeal(DealViewModel dealModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            DealDto dealDto = new DealDto();

            dealDto.User1_Login = User.Identity.Name;
            dealDto.User2_Login = dealModel.viewModel.User2_Login;
            dealDto.Building_Name = dealModel.viewModel.Building_Name;
            if (dealModel.viewModel.Owner == true)
            {
                dealDto.Map_ID = 1;
            }
            else
            {
                dealDto.Map_ID = 0;
            }
            var temp = dealModel.viewModel.Value;
            dealDto.Percent_User1 = dealModel.viewModel.Percent_User1;
            dealDto.FinishDate = (DateTime.Now.AddDays(dealModel.viewModel.DealDay));
            dealDto.DayTime = dealModel.viewModel.DealDay;

            if (dealDto.User2_Login != User.Identity.Name)
            {
                foreach (var item in _dealService.AddDeal(dealDto))
                {
                    if (item == 1)
                    {
                        NotificationDto notificationDto = new NotificationDto();

                        notificationDto.Description = "Nowa umowa";
                        notificationDto.User_Login = dealModel.viewModel.User2_Login;

                        _notificationService.SentNotification(notificationDto);

                        errors.Add("Oferta złożona");
                    }
                    else if (item == 2)
                    {
                        errors.Add("Taki budyenk nie istnieje.");
                    }
                    else if (item == 0)
                    {
                        errors.Add("Taki użytkownik nie istnieje.");
                    }
                    else if (item == 3)
                    {
                        errors.Add("Nie stać Cię na taką umowę.");
                    }
                }
            }
            else if (dealDto.User2_Login == User.Identity.Name)
            {
                errors.Add("Nie możesz złożyć oferty samemu sobie");
            }

            Session["val"] = errors.ToArray<string>();
            return RedirectToAction("Index");
        }
예제 #2
0
        public ActionResult AddDeal(DealViewModel dealModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            DealDto dealDto = new DealDto();

            dealDto.Building_Name = dealModel.viewModel.Building_Name;
            dealDto.DayTime = dealModel.viewModel.DealDay;
            dealDto.IsActive = dealModel.viewModel.Active.ToLower().Contains("tak")? true : false;
            dealDto.OwnerLogin = dealModel.viewModel.OwnerLogin.ToLower().Contains("użytkownik 1") ? dealModel.viewModel.User1_Login : dealModel.viewModel.User2_Login;
            dealDto.Percent_User1 = dealModel.viewModel.Percent_User1;
            dealDto.Percent_User2 = dealModel.viewModel.Percent_User2;
            dealDto.User2_Login = dealModel.viewModel.User2_Login;
            dealDto.User1_Login = dealModel.viewModel.User1_Login;

            if(_dealService.AddDealAdmin(dealDto))
            {
                errors.Add("Dodano umowę.");
            }
            else
            {
                errors.Add("Błąd. Spróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }
예제 #3
0
        public ActionResult _UserDealList()
        {
            DealViewModel dealModel = new DealViewModel();

            dealModel.listModel = _dealService.GetUserDeals(User.Identity.Name).Select(x => new ItemDealViewModel
            {
                ID = x.ID,
                User1_Login = x.User1_Login,
                User2_Login = x.User2_Login,
                Percent_User1 = x.Percent_User1,
                Percent_User2 = x.Percent_User2,
                Building_Name = x.Building_Name,
                IsActive = x.IsActive,
                Owner = x.MyMap,
                Value = x.FinishDate.Value.Subtract(DateTime.Now).Minutes,
                DayToEnd = x.FinishDate.Value.Subtract(DateTime.Now).Days,
                DealDay = x.DayTime,
            }).ToList();

            //dealModel.buildingList = new string [ _buildingsHelper.GetBuildings().OrderBy(x => x.Alias).Select(x => x.Alias).ToString(), Convert.ToString(_buildingsHelper.GetBuildings().OrderBy(x => x.Alias).Select(x => x.Price))];
            dealModel.buildingList2 = new List<SelectListItem>();
            foreach (var item in _buildingsHelper.GetBuildings())
            {
                dealModel.buildingList2.Add(new SelectListItem
                {
                    Value = item.Alias,
                    Text = item.Alias +" - $"+ item.Price.ToString()
                });
            }

            List<string> temp = new List<string>();
            int i = 0;
            foreach (var item in _userService.GetUser())
            {
                if (!_userService.Ignored(User.Identity.Name, item.Login) && (item.Login != User.Identity.Name))
                {
                    temp.Add(item.Login);
                }
                i++;
            }

            dealModel.userList = temp.ToArray();

            Array.Sort(dealModel.userList);

            return View(dealModel);
        }
예제 #4
0
        public ActionResult _DealList()
        {
            DealViewModel dealModel = new DealViewModel();

            dealModel.listModel = _dealService.GetDeals().Select(x => new ItemDealViewModel
            {
                Building_Name = x.Building_Name,
                DealDay = x.DayTime,
                ID = x.ID,
                Active = (x.IsActive==true ? "Tak":"Nie"),
                Value = x.Map_ID,
                Percent_User1 = x.Percent_User1,
                Percent_User2 = x.Percent_User2,
                User1_Login = x.User1_Login,
                User2_Login = x.User2_Login,
                FinishDate = (DateTime)x.FinishDate
            }).ToList();

            dealModel.buildingList = _buildingService.GetBuilding().Select(x => x.Alias).ToArray();
            dealModel.userList = _userService.GetUser().Select(x => x.Login).ToArray();
            return View(dealModel);
        }