public async Task <IActionResult> Index()
        {
            var specialist = await _specialistService.FindAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));

            var orders = await _orderService.FindAllForSpecialistAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (!orders.Any())
            {
                orders = new List <Order>();
            }
            var isRu = CultureInfo.CurrentCulture.Name == "ru-RU";

            var model = orders.Select(m => new OrderViewModel
            {
                Id = m.Id,
                IsEnoughMoneyOnBalance = specialist.Balance > 1,
                State              = m.State,
                Created            = m.Created,
                ServiceDescription = isRu ? m.Service.DescriptionRU : m.Service.DescriptionAZ,
                ClientId           = m.ClientId,
                ClientImage        = m.Client.ImageUrl,
                ClientFullName     = $"{m.Client.Name} {m.Client.Surname}",
            });

            return(View(model));
        }
Exemple #2
0
        public async Task <IActionResult> SelectSpecialist(int orderId, string specialistId)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var client = await _clientService.FindAsync(userId, true);

            var order = client.Orders.FirstOrDefault(m => m.Id == orderId);

            if (order == null)
            {
                return(Json(false));
            }

            var specialist = await _specialistService.FindAsync(specialistId);

            if (specialist == null)
            {
                return(Json(false));
            }

            order.SpecialistId = specialist.Id;
            order.State        = OrderStateTypeEnum.InProcess;
            order.IsActive     = false;
            await _orderService.UpdateAsync(order);

            return(Json(true));
        }
Exemple #3
0
        public async Task <IActionResult> EditContacts()
        {
            var userId     = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var specialist = await _specialistService.FindAsync(userId, true);

            var model = new ContactsViewModel()
            {
                Name        = specialist.Name,
                Surname     = specialist.Surname,
                Fathername  = specialist.Fathername,
                PhoneNumber = specialist.AppUser.PhoneNumber,
                Email       = specialist.AppUser.Email
            };

            return(View(model));
        }
        public async Task <ActionResult> CreateResponse(int orderId)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var user   = await _userManager.FindByIdAsync(userId);

            if (!user.EmailConfirmed)
            {
                TempData["Notification"] = "Confirm your email !";
                return(RedirectToAction("Index", "Home"));
            }

            var myOrder = await _specialistService.HaveIThisOrder(userId, orderId);

            if (myOrder)
            {
                return(RedirectToAction("MyOrders", "Order", new { area = "SpecialistArea" }));
            }

            var order = await _orderService.FindAsync(orderId);

            var specialist = await _specialistService.FindAsync(userId);

            if (specialist.Balance > 1)
            {
                specialist.Balance -= 1;
                await _specialistService.UpdateAsync(specialist);
            }

            var dialog = new UserSpecialistMessage
            {
                ClientId     = order.ClientId,
                SpecialistId = specialist.Id,
                OrderId      = orderId
            };

            await _messageService.WriteDialogAsync(dialog, new Message
            {
                Author = userId,
                Text   = $"{specialist.Name} {specialist.Surname} предлагает вам сотрудничество!"
            });

            return(RedirectToAction("Conversation", "Order", new { area = "SpecialistArea", orderId }));
        }
Exemple #5
0
        public async Task Send(MessageDTO message)
        {
            if (message.ImgPaths?.Count() == 0 && message.Message.IsNullOrWhiteSpace())
            {
                return;
            }

            var currentUserId = Context.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var msg           = new Message
            {
                Text            = message.Message ?? "",
                Author          = currentUserId,
                AuthorImagePath = message.AuthorImageUrl,
                ImagePaths      = message.ImgPaths?.ToList() ?? new List <string>()
            };

            if (_onlineUsers.Contains(message.ReceiverId))
            {
                await this.Clients.User(message.ReceiverId).SendAsync("ReceiveMessage", msg);
            }
            else
            {
                var fullName = "";
                var role     = "";
                if (Context.User.IsInRole("client"))
                {
                    role = "client";
                    var client = await _clientService.FindAsync(currentUserId);

                    fullName = client.Name + " " + client.Surname;
                }
                else if (Context.User.IsInRole("specialist"))
                {
                    role = "specialist";
                    var specialist = await _specialistService.FindAsync(currentUserId);

                    fullName = specialist.Name + " " + specialist.Surname;
                }

                var text = $"From {fullName} {msg.DateTime.ToShortTimeString()}";
                await _hubContext.Clients.User(message.ReceiverId).SendAsync("NewMsgCame", new { dialogId = message.DialogId, text, role });
            }

            await _messageService.WriteDialogAsync(message.DialogId, msg);
        }
        public async Task <IActionResult> RedirectionAfterSignIn()
        {
            if (User.IsInRole("specialist"))
            {
                var specialist = await _specialistService.FindAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));

                Response.Cookies.Append("profileImage", specialist.ImageUrl ?? "");
                return(RedirectToAction("Index", "Order", new { area = "SpecialistArea" }));
            }

            if (User.IsInRole("client"))
            {
                var client = await _clientService.FindAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));

                Response.Cookies.Append("profileImage", client.ImageUrl ?? "");
                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #7
0
        public async Task <IActionResult> Index()
        {
            var userId     = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var specialist = await _specialistService.FindAsync(userId, true);

            specialist.Educations = await _specialistService.FindEducationsBySpecialist(specialist.Id);

            specialist.Experiences = await _specialistService.FindExperiencesBySpecialist(specialist.Id);

            return(View(specialist));
        }