Ejemplo n.º 1
0
        public ActionResult ShowTask(TasksManager od, string check)
        {
            TaskObj task = new TaskObj();

            if (check == "on")
            {
                od.Status = true;
                NotificationObj.Add(new Notification {
                    AspNetUserId = Guid.Parse("3950eec4-39b4-4b16-a4e7-c7e7e3f978c8"), Url = Url.Content("~/Task/Index"), Status = false, Message = "Данный пользователь" + obj.ViewUserName(od.UserId).UserName + " выполнил задания."
                });
            }
            obj.Edit(od);
            return(RedirectToAction("Calendar"));
        }
Ejemplo n.º 2
0
        public ActionResult PrivateChat(Guid?Id, string chatMessage = "", bool logOn = true, bool enter = true)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("~/Home"));
            }
            IHubContext context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            readMessage(Guid.Parse(Id.ToString()), Guid.Parse(User.Identity.GetUserId()));
            var db    = new ApplicationDbContext();
            var us    = UserOnline.chatModel;
            var query = from messe in db.ChatMessages.ToList()
                        where ((messe.UserSetId == Guid.Parse(User.Identity.GetUserId())) && (messe.UserGetId == Id)) || ((messe.UserGetId == Guid.Parse(User.Identity.GetUserId())) && (messe.UserSetId == Id))
                        select new ChatMessage()
            {
                Id        = messe.Id,
                Date      = messe.Date,
                Text      = messe.Text,
                UserGet   = messe.UserGet,
                UserGetId = messe.UserGetId,
                UserSet   = messe.UserSet,
                UserSetId = messe.UserSetId
            };
            var online = from onl in UserOnline.chatModel.Users.ToList()
                         where onl.Name != User.Identity.Name
                         select onl;



            ViewBag.online   = online.ToList();
            ViewBag.newUsers = db.Users.ToList();
            ViewBag.query    = query;
            ViewBag.Users    = us.Users;


            if (logOn == false)
            {
                return(View("PrivateChat", chatMes));
            }
            else
            {
                if (!string.IsNullOrEmpty(chatMessage))
                {
                    if (online.Count() != 0)
                    {
                        chatMes.Read = true;
                    }
                    else
                    {
                        chatMes.Read = false;
                    }
                    chatMes.Date      = DateTime.Now;
                    chatMes.Text      = chatMessage;
                    chatMes.UserSetId = Guid.Parse(User.Identity.GetUserId());
                    chatMes.UserGetId = Id;
                    db.ChatMessages.Add(chatMes);
                    db.SaveChanges();
                    query = from messe in db.ChatMessages.ToList()
                            where ((messe.UserSetId == Guid.Parse(User.Identity.GetUserId())) && (messe.UserGetId == Id)) || ((messe.UserGetId == Guid.Parse(User.Identity.GetUserId())) && (messe.UserSetId == Id))
                            select new ChatMessage()
                    {
                        Id        = messe.Id,
                        Date      = messe.Date,
                        Text      = messe.Text,
                        UserGet   = messe.UserGet,
                        UserGetId = messe.UserGetId,
                        UserSet   = messe.UserSet,
                        UserSetId = messe.UserSetId
                    };
                    context.Clients.User(obj.ViewUserName(Guid.Parse(Id.ToString())).UserName).UserSend(User.Identity.Name);
                    context.Clients.All.updt();
                    ViewBag.query = query;
                    return(PartialView("PrivateChatHistory", chatMes));
                }
                else if (enter)
                {
                    enter = false;
                    if (!Request.IsAjaxRequest())
                    {
                        return(View(chatMes));
                    }
                    return(PartialView("PrivateChat", chatMes));
                }
                else
                {
                    if (!Request.IsAjaxRequest())
                    {
                        return(View(chatMes));
                    }
                    return(PartialView("PrivateChatHistory", chatMes));
                }
            }
        }