Beispiel #1
0
        public void SentNotification(NotificationDto not)
        {
            int temp = 0;
            if (not.Description.Contains("zaproszenie"))
            {
                temp = _users.GetAll().First(i => i.Login == not.SenderLogin).ID;
            }
            else if (not.Description.Contains("wiadomość"))
            {
                int uID = _users.GetAll().First(i => i.Login == not.User_Login).ID;
                temp = _message.GetAll().OrderByDescending(i => i.ID).First(i => i.Customer_ID == uID).ID;
            }
            else if (not.Description.Contains("umowa"))
            {
                int uID = _users.GetAll().First(i => i.Login == not.User_Login).ID;
                temp = _deal.GetAll().OrderByDescending(i => i.ID).First(i => i.User2_ID == uID).ID;

            }

            _notification.Add(new Notifications
            {
                User_ID = _users.GetAll().First(i => i.Login == not.User_Login).ID,
                Temp_ID = temp,
                Description = not.Description,
                IfRead = false
            });
            _unitOfWork.Commit();
        }
Beispiel #2
0
        public JsonResult AcceptDeal(int a, string user)
        {
            var accepted = _dealService.AcceptDeal(a, User.Identity.Name);
            if (accepted)
            {

                NotificationDto notificationDto = new NotificationDto();

                notificationDto.Description = "Umowa zaakceptowana";
                notificationDto.User_Login = user;

                _notificationService.SentNotification(notificationDto);
                return new JsonResult { Data = true };
            }
            else
            {
                return new JsonResult { Data = false };
            }
        }
Beispiel #3
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");
        }
Beispiel #4
0
        public void RerunDeal(int a, string user)
        {
            _dealService.RerunDeal(a, User.Identity.Name);

            NotificationDto notificationDto = new NotificationDto();

            notificationDto.Description = "Odnowienie umowy";
            notificationDto.User_Login = user;

            _notificationService.SentNotification(notificationDto);
        }
Beispiel #5
0
        public JsonResult CancelDeal(int a, string user)
        {
            _dealService.CancelDeal(a);
            if (user != null)
            {
                NotificationDto notificationDto = new NotificationDto();

                notificationDto.Description = "Umowa odrzucona";
                notificationDto.User_Login = user;

                _notificationService.SentNotification(notificationDto);
            }

            return new JsonResult { Data = true };
        }