Exemplo n.º 1
0
        public ActionResult Create(UserProfile userProfile)
        {
            //HttpPostedFileBase usrImg = Request.Files["userImage"];
            //if (usrImg != null)
            //{
            //    string pic = System.IO.Path.GetFileName(usrImg.FileName);
            //    string path = System.IO.Path.Combine(Server.MapPath("../images/Profile"), pic);
            //    usrImg.SaveAs(path);

            //    userProfile.UserImage = string.Concat("../images/Profile/", pic);

            //    using (MemoryStream ba = new MemoryStream())
            //    {
            //        usrImg.InputStream.CopyTo(ba);
            //        byte[] array = ba.GetBuffer();
            //    }
            //}


            db.UserProfiles.Add(userProfile);
            db.SaveChanges();
            //ViewBag.status = "Your Registration is Compleated Successfully go to Home Page";
            ViewBag.Role = new SelectList(db.UserRoles, "Id", "RoleName", userProfile.Role);
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Create([Bind(Include = "Id,Username,Email,Password,ConfirmPassword,UserroleName,UserState,UserDistrict,UserTaluk,UserGramapanchayath,UserVillage,UserId,OperationUnit")] ManageUser manageUser)
        {
            if (ModelState.IsValid)
            {
                db.ManageUsers.Add(manageUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(manageUser));
        }
        public ActionResult Create([Bind(Include = "CourseId,CourseName,Domain,Type,Duration,Fee,TrainerName,IsEnabled,CreatedOn,CreatedBy")] CourseDetail courseDetail)
        {
            if (ModelState.IsValid)
            {
                db.CourseDetails.Add(courseDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(courseDetail));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,RoleName")] UserRole userRole)
        {
            if (ModelState.IsValid)
            {
                db.UserRoles.Add(userRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userRole));
        }
Exemplo n.º 5
0
        public void Connect(string userName)
        {
            var id = Context.ConnectionId;
            Sdo_ChatEntities dc = new Sdo_ChatEntities();
            var ctx             = new Sdo_ChatEntities();
            var userDetail      =
                (from m in ctx.UserProfiles
                 where m.UserName == userName
                 select new { m.UserName, m.UserImage, m.FolderId, m.Email }).FirstOrDefault();

            if (userDetail != null)
            {
                if (ConnectedUsers.Count(x => x.ConnectionId == id) == 0)
                {
                    //ConnectedUsers.Add(new UserDetail { ConnectionId = id, UserName = userName, UserImage = userDetail.UserImage });

                    var item = dc.UserDetails.FirstOrDefault(x => x.UserName == userName);
                    if (item != null)
                    {
                        dc.UserDetails.Remove(item);
                        dc.SaveChanges();

                        // Disconnect
                        Clients.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName, item.UserImage, item.FolderId);
                    }

                    var Users = dc.UserDetails.ToList();
                    if (Users.Where(x => x.UserName == userName).ToList().Count == 0)
                    {
                        var userdetails = new UserDetail
                        {
                            ConnectionId = id,
                            UserName     = userName,
                            UserImage    = userDetail.UserImage,
                            FolderId     = userDetail.FolderId
                        };
                        dc.UserDetails.Add(userdetails);
                        dc.SaveChanges();

                        // send to caller
                        var connectedUsers = dc.UserDetails.ToList();
                        var CurrentMessage = dc.ChatMessageDetails.ToList();

                        // send to caller
                        Clients.Caller.onConnected(id, userName, connectedUsers, CurrentMessage);
                    }

                    // send to all except caller client
                    Clients.AllExcept(id).onNewUserConnected(id, userName, userDetail.UserImage);
                }
            }
        }
Exemplo n.º 6
0
        //endregion

        //region private Messages

        private void AddMessageinCache(string userName, string message)
        {
            //CurrentMessage.Add(new MessageDetail { UserName = userName, Message = message });

            //if (CurrentMessage.Count > 100)
            //    CurrentMessage.RemoveAt(0);

            var fldr         = new Sdo_ChatEntities();
            var folderDetail =
                (from m in fldr.UserProfiles
                 where m.UserName == userName
                 select new { m.FolderId }).FirstOrDefault();

            if (folderDetail != null)
            {
                using (Sdo_ChatEntities dc = new Sdo_ChatEntities())
                {
                    var messageDetail = new ChatMessageDetail
                    {
                        UserName = userName,
                        Message  = message,
                        EmailID  = emailIDLoaded,
                        FolderId = folderDetail.FolderId,
                        MsgTime  = Convert.ToString(DateTime.Now.ToString("HH:mm:ss")),
                        MsgDate  = Convert.ToString(DateTime.Now)
                    };
                    dc.ChatMessageDetails.Add(messageDetail);
                    dc.SaveChanges();
                }
            }
        }
Exemplo n.º 7
0
        private void DeleteMessages()
        {
            Sdo_ChatEntities db = new Sdo_ChatEntities();

            var all = from c in db.ChatMessageDetails select c;

            db.ChatMessageDetails.RemoveRange(all);
            db.SaveChanges();
        }
Exemplo n.º 8
0
        private void AddPrivateMessageinCache(string chatToUser, string userName, string message)
        {
            using (Sdo_ChatEntities dc = new Sdo_ChatEntities())
            {
                // Save master
                var master = dc.ChatPrivateMessageMasters.ToList().Where(a => a.UserName.Equals(userName)).ToList();
                if (master.Count == 0)
                {
                    var result = new ChatPrivateMessageMaster
                    {
                        UserName = userName
                    };
                    dc.ChatPrivateMessageMasters.Add(result);
                    dc.SaveChanges();
                }

                // Save details

                var fldrone         = new Sdo_ChatEntities();
                var folderDetailone =
                    (from m in fldrone.UserProfiles
                     where m.UserName == userName
                     select new { m.FolderId }).FirstOrDefault();

                if (folderDetailone != null)
                {
                    var resultDetails = new ChatPrivateMessageDetail
                    {
                        MasterEmailID = userName,
                        ChatToEmailID = chatToUser,
                        Message       = message,
                        FolderId      = folderDetailone.FolderId,
                        MsgTime       = Convert.ToString(DateTime.Now.ToString("HH:mm:ss")),
                        MsgDate       = Convert.ToString(DateTime.Now)
                    };
                    dc.ChatPrivateMessageDetails.Add(resultDetails);
                    dc.SaveChanges();
                }
            }
        }
Exemplo n.º 9
0
        public ActionResult AssignRole(FormCollection collection)
        {
            //string username = collection["UserId"];
            //string rolename = collection["Roles"];
            int         userId      = Convert.ToInt32(collection["UserId"]);
            int         roleId      = Convert.ToInt32(collection["Roles"]);
            UserProfile userProfile = new UserProfile();

            userProfile      = db.UserProfiles.Where(c => c.Id == userId).Select(c => c).First();
            userProfile.Role = roleId;
            if (ModelState.IsValid)
            {
                db.Entry(userProfile).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }