示例#1
0
        // PUT api/WallPost/5
        public HttpResponseMessage PutPost(int id, Post post)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != post.PostId)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(post).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        //
        // GET: /Verification/

        public ActionResult Verify(string useradminid, string Useraccess)
        {
            if (Useraccess != null)
            {
                using (WallEntities db = new WallEntities())
                {
                    AuthenticationUser authuser = db.AuthenticationUsers.Where(a => a.UserAccess == Useraccess && a.UserAdmin == useradminid).FirstOrDefault();
                    authuser.Verification = "Verify";
                    db.SaveChanges();
                }
            }

            return(View());
        }
示例#3
0
        // POST api/WallPost
        public HttpResponseMessage PostPost(Post post)
        {
            using (var db = new WallEntities())
            {
                post.PostedBy   = WebSecurity.CurrentUserId;
                post.PostedDate = DateTime.UtcNow;
                ModelState.Remove("post.PostedBy");
                ModelState.Remove("post.PostedDate");

                if (ModelState.IsValid)
                {
                    try
                    {
                        db.Database.Connection.Open();
                        db.Posts.Add(post);
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        string err = e.Message;
                    }

                    var usr = db.UserProfiles.FirstOrDefault(x => x.UserId == post.PostedBy);
                    var ret = new
                    {
                        Message        = post.Message,
                        PostedBy       = post.PostedBy,
                        PostedByName   = usr.UserName,
                        PostedByAvatar = imgFolder + (String.IsNullOrEmpty(usr.AvatarExt) ? defaultAvatar : post.PostedBy + "." + post.UserProfile.AvatarExt),
                        PostedDate     = post.PostedDate,
                        PostId         = post.PostId
                    };
                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ret);
                    response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = post.PostId }));
                    return(response);
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
        }
示例#4
0
 public dynamic AddComment(PostComment postcomment)
 {
     postcomment.CommentedBy   = WebSecurity.CurrentUserId;
     postcomment.CommentedDate = DateTime.UtcNow;
     using (WallEntities db = new WallEntities())
     {
         db.PostComments.Add(postcomment);
         db.SaveChanges();
         var usr = db.UserProfiles.FirstOrDefault(x => x.UserId == postcomment.CommentedBy);
         var ret = new
         {
             CommentedBy       = postcomment.CommentedBy,
             CommentedByName   = usr.UserName,
             CommentedByAvatar = imgFolder + (String.IsNullOrEmpty(usr.AvatarExt) ? defaultAvatar : postcomment.CommentedBy + "." + postcomment.UserProfile.AvatarExt),
             CommentedDate     = postcomment.CommentedDate,
             CommentId         = postcomment.CommentId,
             Message           = postcomment.Message,
             PostId            = postcomment.PostId
         };
         Clients.Others.newComment(ret, postcomment.PostId);
         return(ret);
     }
 }
示例#5
0
        public void AddPost(Post post)
        {
            post.PostedBy   = WebSecurity.CurrentUserId;
            post.PostedDate = DateTime.UtcNow;
            using (WallEntities db = new WallEntities())
            {
                db.Posts.Add(post);
                db.SaveChanges();
                var usr = db.UserProfiles.FirstOrDefault(x => x.UserId == post.PostedBy);
                var ret = new
                {
                    Message        = post.Message,
                    PostedBy       = post.PostedBy,
                    PostedByName   = usr.UserName,
                    PostedByAvatar = imgFolder + (String.IsNullOrEmpty(usr.AvatarExt) ? defaultAvatar : post.PostedBy + "." + post.UserProfile.AvatarExt),
                    PostedDate     = post.PostedDate,
                    PostId         = post.PostId
                };

                Clients.Caller.addPost(ret);
                Clients.Others.newPost(ret);
            }
        }
示例#6
0
        public ActionResult AuthenticateAccess(AuthenticationUser authmodel, string[] type)
        {
            if (authmodel != null && type != null)
            {
                if (Session["UserId"] != null)
                {
                    userId = Session["UserId"].ToString();
                }
                authmodel.UserAdmin = userId;
                //string emailid = authmodel.EmailId.ToString();
                string         username = Membership.GetUserNameByEmail(authmodel.EmailId);
                MembershipUser user     = Membership.GetUser(username);
                authmodel.UserAccess    = user.ProviderUserKey.ToString();
                authmodel.UserAdminName = Session["UserName"].ToString();
                authmodel.Verification  = "Unverify";
                foreach (var tp in type)
                {
                    if (authmodel.AccessType != null)
                    {
                        authmodel.AccessType = authmodel.AccessType + "," + tp.ToString();
                    }
                    else
                    {
                        authmodel.AccessType = tp.ToString();
                    }
                }
                if (authmodel.UserAccess != null)
                {
                    var usercheck = db.AuthenticationUsers.ToList().Last();
                    if (usercheck == null)
                    {
                        authmodel.Authuserid = 1;
                    }
                    else
                    {
                        authmodel.Authuserid = usercheck.Authuserid + 1;
                    }
                    var useraccss   = authmodel.UserAccess;
                    var verifyurl   = "http://*****:*****@gmail.com",
                                                            "pooja123456")
                    };
                    smtp.Send(mm);
                    ViewBag.Message = "Verification mail send successful";
                }
                else
                {
                    ViewBag.Message = "There is No user has this EmailId";
                }
            }
            else
            {
                ViewBag.Message = "Please enter emailid";
            }
            return(View());
        }