示例#1
0
        public JsonResult Eventdata(string EventId)
        {
            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();
                using (SqlCommand eventview = new SqlCommand("USPEventView", dbHandle.con))
                {
                    eventview.CommandType = CommandType.StoredProcedure;
                    dbHandle.con.Open();

                    Session["eventId"] = EventId;
                    dbHandle.con.Close();
                    return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                Dispose();
            }
        }
示例#2
0
 public JsonResult EventProfile()
 {
     try
     {
         if (Session["companyid"] != null)
         {
             DbConnection dbHandle = new DbConnection();
             DataTable    eventProfiledataTable = new DataTable();
             dbHandle.Connection();
             using (SqlCommand eventprofile = new SqlCommand("USPSingleEventView", dbHandle.con))
             {
                 eventprofile.CommandType = CommandType.StoredProcedure;
                 eventprofile.Parameters.AddWithValue("@CompanyId", Session["companyid"]);
                 eventprofile.Parameters.AddWithValue("@EventId", Session["eventId"]);
                 dbHandle.con.Open();
                 SqlDataReader reader = eventprofile.ExecuteReader();
                 eventProfiledataTable.Load(reader);
                 dbHandle.con.Close();
                 return(Json(JsonConvert.SerializeObject(eventProfiledataTable), JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
     }
     finally
     {
         Dispose();
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
示例#3
0
        public JsonResult FetchGroupMessage(int groupId, int cId, int userId)
        {
            DbConnection dbHandle = new DbConnection();

            dbHandle.Connection();
            DataTable dataTable = new DataTable();

            try
            {
                using (SqlCommand groupChatcmd = new SqlCommand("USPSelectGroupChatMessage", dbHandle.con))
                {
                    groupChatcmd.CommandType = CommandType.StoredProcedure;
                    groupChatcmd.Parameters.AddWithValue("@userid", SqlDbType.Int).Value  = userId;
                    groupChatcmd.Parameters.AddWithValue("@groupid", SqlDbType.Int).Value = groupId;

                    groupChatcmd.Parameters.AddWithValue("@companyid", SqlDbType.Int).Value = cId;
                    dbHandle.con.Open();
                    using (SqlDataReader reader = groupChatcmd.ExecuteReader())
                    {
                        dataTable.Load(reader);
                    }
                }
                return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(JsonRequestBehavior.AllowGet));
            }
            finally
            {
                dbHandle.con.Close();
                Dispose();
            }
        }
示例#4
0
 public JsonResult BlockOrUnblockCompany(string CompanyId, string blockOperation)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand blockorunblock = new SqlCommand("USPApproveOrDisApproveCompany", dbHandle.con))
         {
             blockorunblock.Connection = dbHandle.con;
             dbHandle.con.Open();
             blockorunblock.CommandType = CommandType.StoredProcedure;
             blockorunblock.Parameters.Add("@CompanyId", SqlDbType.Int).Value = Convert.ToInt32(CompanyId);
             blockorunblock.Parameters.Add("@Operation", SqlDbType.Int).Value = Convert.ToInt32(blockOperation);
             blockorunblock.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         ExceptionLog.Log(ex, Request.UserHostAddress);
         return(Json(new { id = ex }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#5
0
        public JsonResult FetchUserList(int uId, int cId)
        {
            DbConnection dbHandle = new DbConnection();

            dbHandle.Connection();
            DataTable dataTable = new DataTable();

            try
            {
                using (SqlCommand listEmpcmd = new SqlCommand("USPEmployeeList", dbHandle.con))
                {
                    listEmpcmd.CommandType = CommandType.StoredProcedure;
                    listEmpcmd.Parameters.AddWithValue("@CompanyId", SqlDbType.Int).Value = cId;
                    listEmpcmd.Parameters.AddWithValue("@UserId", SqlDbType.Int).Value    = uId;
                    dbHandle.con.Open();
                    using (SqlDataReader reader = listEmpcmd.ExecuteReader())
                    {
                        dataTable.Load(reader);
                    }
                }
                return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(JsonRequestBehavior.AllowGet));
            }
            finally
            {
                dbHandle.con.Close();
                Dispose();
            }
        }
示例#6
0
        public JsonResult MessageRead(int tId, int cId, int fId)
        {
            DbConnection dbHandle = new DbConnection();

            dbHandle.Connection();
            int flag = 0;

            try
            {
                using (SqlCommand msgReadcmd = new SqlCommand("USPMessageRead", dbHandle.con))
                {
                    msgReadcmd.CommandType = CommandType.StoredProcedure;
                    msgReadcmd.Parameters.AddWithValue("@FromId", SqlDbType.Int).Value = fId;
                    msgReadcmd.Parameters.AddWithValue("@ToId", SqlDbType.Int).Value   = tId;
                    dbHandle.con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(msgReadcmd);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                }
                return(Json(new { id = flag }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(JsonRequestBehavior.AllowGet));
            }
            finally
            {
                dbHandle.con.Close();
                Dispose();
            }
        }
示例#7
0
 //Admin Delete Group
 public JsonResult DeleteGroups()
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand deletegroup = new SqlCommand("USPDeleteGroup", dbHandle.con))
         {
             deletegroup.Connection = dbHandle.con;
             dbHandle.con.Open();
             deletegroup.CommandType = CommandType.StoredProcedure;
             SqlParameter parm = new SqlParameter("@userId", SqlDbType.Int);
             parm.Direction = ParameterDirection.ReturnValue;
             deletegroup.Parameters.Add(parm);
             deletegroup.Parameters.Add("@GroupId", SqlDbType.Int).Value   = Session["groupId"];
             deletegroup.Parameters.Add("@CompanyId", SqlDbType.Int).Value = Session["companyid"];
             SqlDataAdapter da = new SqlDataAdapter(deletegroup);
             DataSet        ds = new DataSet();
             da.Fill(ds);
             int flag = Convert.ToInt32(parm.Value);
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 0 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#8
0
 public JsonResult PostData(string id, string notId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand groupsession = new SqlCommand("USPPostSession", dbHandle.con))
         {
             groupsession.CommandType = CommandType.StoredProcedure;
             dbHandle.con.Open();
             Session["postIdView"] = id;
             Session["postReadId"] = notId;
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#9
0
 //Remove Group members
 public JsonResult RemoveGrpMember(string userTockenId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand removemember = new SqlCommand("USPRemoveGroupMember", dbHandle.con))
         {
             removemember.Connection = dbHandle.con;
             dbHandle.con.Open();
             removemember.CommandType = CommandType.StoredProcedure;
             SqlParameter parm = new SqlParameter("@userId", SqlDbType.Int);
             parm.Direction = ParameterDirection.ReturnValue;
             removemember.Parameters.Add(parm);
             removemember.Parameters.Add("@FK_GroupId", SqlDbType.Int).Value = Session["groupId"];; //Session["userid"];
             removemember.Parameters.Add("@UserId", SqlDbType.VarChar).Value = userTockenId;
             SqlDataAdapter da = new SqlDataAdapter(removemember);
             DataSet        ds = new DataSet();
             da.Fill(ds);
             int flag = Convert.ToInt32(parm.Value);
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 0 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#10
0
 //Group Name Validation
 public JsonResult GroupValidation(string groupName)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand grpvalidation = new SqlCommand("USPCheckGroupName", dbHandle.con))
         {
             grpvalidation.Connection = dbHandle.con;
             dbHandle.con.Open();
             grpvalidation.CommandType = CommandType.StoredProcedure;
             SqlParameter parm = new SqlParameter("@flag", SqlDbType.Int);
             parm.Direction = ParameterDirection.ReturnValue;
             grpvalidation.Parameters.Add(parm);
             grpvalidation.Parameters.AddWithValue("@GroupName", SqlDbType.Int).Value = groupName;
             SqlDataAdapter da = new SqlDataAdapter(grpvalidation);
             DataSet        ds = new DataSet();
             da.Fill(ds);
             int flag = Convert.ToInt32(parm.Value);
             dbHandle.con.Close();
             return(Json(new { id = flag }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 0 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#11
0
 //Search Group Member Name
 public JsonResult SearchWithNameGroupMember(string procedureName)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         DataTable dataTable = new DataTable();
         using (SqlCommand searchbygrpmember = new SqlCommand(procedureName, dbHandle.con))
         {
             searchbygrpmember.Connection = dbHandle.con;
             dbHandle.con.Open();
             searchbygrpmember.CommandType = CommandType.StoredProcedure;
             searchbygrpmember.Parameters.Add("@UserId", SqlDbType.Int).Value  = Session["userid"];
             searchbygrpmember.Parameters.Add("@GroupId", SqlDbType.Int).Value = Session["groupId"];
             SqlDataReader reader = searchbygrpmember.ExecuteReader();
             dataTable.Load(reader);
             dbHandle.con.Close();
         }
         return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
 //Otp Validation
 public JsonResult OtpValidation(string otp)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand CheckOtp = new SqlCommand("USPOtpVerification", dbHandle.con))
         {
             CheckOtp.Connection = dbHandle.con;
             dbHandle.con.Open();
             CheckOtp.CommandType = CommandType.StoredProcedure;
             SqlParameter parm = new SqlParameter("@flag", SqlDbType.Int);
             parm.Direction = ParameterDirection.ReturnValue;
             CheckOtp.Parameters.Add(parm);
             CheckOtp.Parameters.AddWithValue("@otpNumber", SqlDbType.VarChar).Value = otp;
             SqlDataAdapter da = new SqlDataAdapter(CheckOtp);
             DataSet        ds = new DataSet();
             da.Fill(ds);
             int flag = Convert.ToInt32(parm.Value);
             Session["companyid"] = flag;
             Session["otp"]       = otp;
             dbHandle.con.Close();
             return(Json(new { id = flag }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 0 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
        //DropDown List State
        private static List <SelectListItem> drpList(string procedureName, string text, string value)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            try
            {
                SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConNew"].ConnectionString);
                using (SqlCommand cmd = new SqlCommand(procedureName, con))
                {
                    con.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            items.Add(new SelectListItem
                            {
                                Text  = sdr[text].ToString(),
                                Value = sdr[value].ToString()
                            });
                        }
                    }
                }
                con.Close();
                return(items);
            }
            catch (Exception ex)
            {
                ExceptionLog.Log(ex, "");
                return(items);
            }
            finally
            {
            }
        }
 //Validate Email Id Is Already Exists
 public JsonResult MailCheck(string mailidId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand checkMail = new SqlCommand("USPCheckMail", dbHandle.con))
         {
             checkMail.Connection = dbHandle.con;
             dbHandle.con.Open();
             checkMail.CommandType = CommandType.StoredProcedure;
             SqlParameter parm = new SqlParameter("@flag", SqlDbType.Int);
             parm.Direction = ParameterDirection.ReturnValue;
             checkMail.Parameters.Add(parm);
             checkMail.Parameters.AddWithValue("@email", SqlDbType.VarChar).Value = mailidId;
             SqlDataAdapter da = new SqlDataAdapter(checkMail);
             DataSet        ds = new DataSet();
             da.Fill(ds);
             int flag = Convert.ToInt32(parm.Value);
             dbHandle.con.Close();
             return(Json(new { id = flag }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#15
0
 public JsonResult GroupMemberDisplay()
 {
     try
     {
         DataTable    dataTable = new DataTable();
         DbConnection dbHandle  = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand grpMemberDisplay = new SqlCommand("USPGroupMemberDisplay", dbHandle.con))
         {
             grpMemberDisplay.CommandType = CommandType.StoredProcedure;
             grpMemberDisplay.Parameters.Add("@GroupId", SqlDbType.Int).Value = Session["groupId"];
             dbHandle.con.Open();
             SqlDataReader reader = grpMemberDisplay.ExecuteReader();
             dataTable.Load(reader);
             dbHandle.con.Close();
             return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
     }
     finally
     {
         Dispose();
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
示例#16
0
        public JsonResult NotificationCall()
        {
            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();

                using (SqlCommand Notificationcommand = new SqlCommand("[dbo].[USPNotificationSelect]", dbHandle.con))
                {
                    dbHandle.con.Open();
                    Notificationcommand.Notification = null;
                    Notificationcommand.CommandType  = CommandType.StoredProcedure;
                    Notificationcommand.Parameters.Add("@NotificationToId", SqlDbType.Int).Value = Session["userid"];
                    Notificationcommand.ExecuteNonQuery();
                    SqlDependency dependency = new SqlDependency(Notificationcommand);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
                    SqlDataReader reader = Notificationcommand.ExecuteReader();
                }
                dbHandle.con.Close();
                return(Json(JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(ex, Request.UserHostAddress);
            }
            finally
            {
                Dispose();
            }

            return(Json(JsonRequestBehavior.AllowGet));
        }
示例#17
0
 public JsonResult GroupDisplay()
 {
     try
     {
         DbConnection dbHandle             = new DbConnection();
         DataTable    GroupDisplydataTable = new DataTable();
         dbHandle.Connection();
         using (SqlCommand groupdisplay = new SqlCommand("USPGroupView", dbHandle.con))
         {
             groupdisplay.CommandType = CommandType.StoredProcedure;
             groupdisplay.Parameters.AddWithValue("@UserId", Session["userid"]);
             dbHandle.con.Open();
             SqlDataReader reader = groupdisplay.ExecuteReader();
             GroupDisplydataTable.Load(reader);
             dbHandle.con.Close();
             return(Json(JsonConvert.SerializeObject(GroupDisplydataTable), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#18
0
 public JsonResult InsertComment(string CommentText, string PostId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand groupcommentpost = new SqlCommand("USPGroupCommentPosting", dbHandle.con))
         {
             groupcommentpost.CommandType = CommandType.StoredProcedure;
             groupcommentpost.Parameters.Add("GroupPostId", SqlDbType.Int).Value      = Convert.ToInt32(PostId);
             groupcommentpost.Parameters.Add("@Comment", SqlDbType.VarChar).Value     = CommentText;
             groupcommentpost.Parameters.Add("@CommentedUserId", SqlDbType.Int).Value = Session["userid"];
             groupcommentpost.Parameters.Add("@CompanyId", SqlDbType.Int).Value       = Session["companyid"];
             groupcommentpost.Parameters.Add("@GroupId", SqlDbType.Int).Value         = Session["groupId"];
             dbHandle.con.Open();
             groupcommentpost.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
 //Remove Employee
 public JsonResult RemoveEmployeeById(int userId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand removeempolyees = new SqlCommand("USPRemoveEmployee", dbHandle.con))
         {
             removeempolyees.CommandType = CommandType.StoredProcedure;
             removeempolyees.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
             dbHandle.con.Open();
             removeempolyees.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#20
0
 public JsonResult Insertdislike(string PostId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand groupdislike = new SqlCommand("USPGroupLike", dbHandle.con))
         {
             groupdislike.CommandType = CommandType.StoredProcedure;
             groupdislike.Parameters.Add("@FK_GroupId", SqlDbType.Int).Value = Session["groupId"];
             groupdislike.Parameters.Add("@FK_PostId", SqlDbType.Int).Value  = Convert.ToInt32(PostId);
             groupdislike.Parameters.Add("@FK_UserId", SqlDbType.Int).Value  = Session["userid"];
             groupdislike.Parameters.Add("@CompanyId", SqlDbType.Int).Value  = Session["companyid"];
             groupdislike.Parameters.Add("@Operation", SqlDbType.Int).Value  = 2;
             dbHandle.con.Open();
             groupdislike.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#21
0
 public JsonResult GroupDetails()
 {
     try
     {
         DataTable    dataTable = new DataTable();
         DbConnection dbHandle  = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand singlegroupview = new SqlCommand("USPSingleGroup", dbHandle.con))
         {
             singlegroupview.CommandType = CommandType.StoredProcedure;
             singlegroupview.Parameters.AddWithValue("@GroupId", Session["groupId"]);
             dbHandle.con.Open();
             SqlDataReader reader = singlegroupview.ExecuteReader();
             dataTable.Load(reader);
             dbHandle.con.Close();
             return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
 public JsonResult DeleteUserComment(string CommentId)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand deletePost = new SqlCommand("USPDeleteComment", dbHandle.con))
         {
             deletePost.CommandType = CommandType.StoredProcedure;
             deletePost.Parameters.Add("@CommentId", SqlDbType.Int).Value = Convert.ToInt32(CommentId);
             deletePost.Parameters.Add("@UserId", SqlDbType.Int).Value    = Session["userid"];
             dbHandle.con.Open();
             deletePost.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
示例#23
0
 public JsonResult ShowProfileReplay(string commentid)
 {
     try
     {
         DbConnection dbHandle  = new DbConnection();
         DataTable    dataTable = new DataTable();
         dbHandle.Connection();
         using (SqlCommand userpostcomment = new SqlCommand("UspShowGroupReplay", dbHandle.con))
         {
             userpostcomment.CommandType = CommandType.StoredProcedure;
             userpostcomment.Parameters.Add("@CommentId", SqlDbType.Int).Value = commentid;
             userpostcomment.Parameters.AddWithValue("@userid", Session["userid"]);
             dbHandle.con.Open();
             SqlDataReader reader = userpostcomment.ExecuteReader();
             dataTable.Load(reader);
             dbHandle.con.Close();
             return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
        public JsonResult ProfileDetails()
        {
            try
            {
                DbConnection dbHandle  = new DbConnection();
                DataTable    dataTable = new DataTable();
                dbHandle.Connection();
                using (SqlCommand profiledetails = new SqlCommand("USPProfilePost", dbHandle.con))
                {
                    profiledetails.CommandType = CommandType.StoredProcedure;

                    profiledetails.Parameters.AddWithValue("@UserId", Session["userid"]);
                    profiledetails.Parameters.AddWithValue("@CompanyId", Session["companyid"]);

                    dbHandle.con.Open();

                    SqlDataReader reader = profiledetails.ExecuteReader();
                    dataTable.Load(reader);
                    dbHandle.con.Close();
                    return(Json(JsonConvert.SerializeObject(dataTable), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
            }
            finally
            {
                Dispose();
            }
            return(Json(JsonRequestBehavior.AllowGet));
        }
示例#25
0
        public JsonResult InsertPost()
        {
            string Imagepath = "";

            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();

                string PostMessages = System.Web.HttpContext.Current.Request.Form["postmessage"];
                if (Request.Files.Count > 0)
                {
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        HttpPostedFileBase filebase = Request.Files[i];
                        string             randomNo = System.DateTime.Now.ToString("ddMMyyhhmmss");
                        string             fileName = randomNo + Path.GetFileName(filebase.FileName);
                        Imagepath = Imagepath + "../Images/" + fileName + ',';
                        filebase.SaveAs(Server.MapPath("../Images/") + fileName);
                    }
                }


                using (SqlCommand createpost = new SqlCommand("USPInsertPost", dbHandle.con))
                {
                    createpost.CommandType = CommandType.StoredProcedure;
                    SqlParameter parm = new SqlParameter("@PostId", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    createpost.Parameters.Add(parm);
                    createpost.Parameters.Add("@PostMessage", SqlDbType.VarChar).Value = PostMessages;
                    createpost.Parameters.Add("@FK_UserId", SqlDbType.Int).Value       = Session["userid"];
                    createpost.Parameters.Add("@PostUrl", SqlDbType.VarChar).Value     = Imagepath;
                    if (Imagepath == "")
                    {
                        createpost.Parameters.Add("@FK_PostTypeId", SqlDbType.Int).Value = 3;
                    }
                    else
                    {
                        createpost.Parameters.Add("@FK_PostTypeId", SqlDbType.Int).Value = 1;
                    }
                    createpost.Parameters.Add("@CompanyId", SqlDbType.Int).Value = Session["companyid"];
                    dbHandle.con.Open();
                    createpost.ExecuteNonQuery();
                    int flag = Convert.ToInt32(parm.Value);
                    Session["postid"] = flag;
                    dbHandle.con.Close();
                    return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                Dispose();
            }
        }
示例#26
0
        public JsonResult ShowComment(string showPost)
        {
            try
            {
                DbConnection dbHandle             = new DbConnection();
                DataTable    showCommentdataTable = new DataTable();
                dbHandle.Connection();
                using (SqlCommand viewcmt = new SqlCommand("USPShowComment", dbHandle.con))
                {
                    viewcmt.CommandType = CommandType.StoredProcedure;
                    viewcmt.Parameters.Add("@PostId", SqlDbType.Int).Value = Convert.ToInt32(showPost);
                    dbHandle.con.Open();

                    SqlDataReader reader = viewcmt.ExecuteReader();
                    showCommentdataTable.Load(reader);
                    dbHandle.con.Close();
                    return(Json(JsonConvert.SerializeObject(showCommentdataTable), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                Dispose();
            }
        }
示例#27
0
 public JsonResult InsertReplay(string CommentId, string CommentText)
 {
     try
     {
         DbConnection dbHandle = new DbConnection();
         dbHandle.Connection();
         using (SqlCommand commentpost = new SqlCommand("USPReplies", dbHandle.con))
         {
             dbHandle.con.Open();
             commentpost.CommandType = CommandType.StoredProcedure;
             commentpost.Parameters.Add("@CommentedId", SqlDbType.Int).Value = Convert.ToInt32(CommentId);
             commentpost.Parameters.Add("@Replay", SqlDbType.VarChar).Value  = CommentText;
             commentpost.Parameters.Add("@UserId", SqlDbType.Int).Value      = Session["userid"];
             commentpost.Parameters.Add("@CompanyCode", SqlDbType.Int).Value = Session["companyid"];
             commentpost.ExecuteNonQuery();
             dbHandle.con.Close();
             return(Json(new { id = 1 }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         ViewBag.error = "Error!!";
         ExceptionLog.Log(e, Request.UserHostAddress);
         return(Json(new { id = 404 }, JsonRequestBehavior.AllowGet));
     }
     finally
     {
         Dispose();
     }
 }
        public ActionResult UserProfile(Register Register)
        {
            try
            {
                if (Session["userid"] != null)
                {
                    DbConnection dbHandle = new DbConnection();
                    dbHandle.Connection();
                    using (SqlCommand RegCmd = new SqlCommand("USPProfileView", dbHandle.con))
                    {
                        RegCmd.Connection  = dbHandle.con;
                        RegCmd.CommandType = CommandType.StoredProcedure;
                        if (Session["useridSearch"] != null)
                        {
                            RegCmd.Parameters.AddWithValue("@UserId", Session["useridSearch"]);
                            Session["useridSearch"] = null;
                        }
                        else if (Session["userid"] != null)
                        {
                            RegCmd.Parameters.AddWithValue("@UserId", Session["userid"]);
                        }
                        dbHandle.con.Open();
                        using (SqlDataReader profile = RegCmd.ExecuteReader())
                        {
                            while (profile.Read())
                            {
                                RegCmd.Connection = dbHandle.con;
                                Register.name     = profile["Name"].ToString();
                                DateTime dob = Convert.ToDateTime(profile["DateofBirth"]);
                                Register.dateOfBirth = (dob.Date).ToShortDateString();
                                Register.age         = Convert.ToInt32(profile["Age"]);
                                Register.nationality = profile["Nationality"].ToString();
                                Register.address     = profile["Address"].ToString();
                                Register.mobile      = profile["Mobile"].ToString();
                                Register.email       = profile["Email"].ToString();
                                Register.gender      = profile["Gender"].ToString();
                                Register.companyName = profile["CompanyName"].ToString();
                                Register.UserPhoto   = profile["ImageUrl"].ToString();
                            }
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("LoginUser", "UserLogin"));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
            }
            finally
            {
                Dispose();
            }

            return(View(Register));
        }
        public ActionResult UserRegister(Register Register)
        {
            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();

                using (SqlCommand UserRegistercmd = new SqlCommand("USPUserRegistration", dbHandle.con))
                {
                    if (Session["otp"] != null)
                    {
                        Register.UserTypeID = 1;
                    }
                    DateTime dob    = Convert.ToDateTime(Register.dateOfBirth);
                    string   Random = System.DateTime.Now.ToString("ddMMyyhhmmss");
                    Register.UserPhoto = "../Images/" + Random + Register.userImg.FileName;
                    Register.userImg.SaveAs(Server.MapPath("../Images/") + Random + Register.userImg.FileName);
                    UserRegistercmd.CommandType = CommandType.StoredProcedure;
                    UserRegistercmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value          = Register.firstName;
                    UserRegistercmd.Parameters.Add("@SecondName", SqlDbType.VarChar).Value         = Register.secondName;
                    UserRegistercmd.Parameters.Add("@Dob", SqlDbType.Date).Value                   = dob;
                    UserRegistercmd.Parameters.Add("Age", SqlDbType.Int).Value                     = DateTime.Today.Year - dob.Year;
                    UserRegistercmd.Parameters.Add("@Gender", SqlDbType.Int).Value                 = int.Parse(Register.gender);
                    UserRegistercmd.Parameters.AddWithValue("@DesignationId", SqlDbType.Int).Value = Register.DesignationId;
                    UserRegistercmd.Parameters.Add("@CompanyCode", SqlDbType.VarChar).Value        = Session["companyid"];
                    UserRegistercmd.Parameters.Add("@Address", SqlDbType.VarChar).Value            = Register.address;
                    UserRegistercmd.Parameters.Add("@Nationality", SqlDbType.VarChar).Value        = Register.nationality;
                    UserRegistercmd.Parameters.Add("@Mobile", SqlDbType.VarChar).Value             = Register.mobile;
                    UserRegistercmd.Parameters.Add("@Email", SqlDbType.VarChar).Value              = Register.email;
                    UserRegistercmd.Parameters.Add("@UserType", SqlDbType.Int).Value               = Register.UserTypeID;
                    UserRegistercmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value           = Register.username;
                    UserRegistercmd.Parameters.Add("@Password", SqlDbType.VarChar).Value           = Crypto.Encryption(Register.password);
                    UserRegistercmd.Parameters.Add("@ImageUrl", SqlDbType.VarChar).Value           = Register.UserPhoto;
                    UserRegistercmd.Parameters.Add("@UserStatus", SqlDbType.Int).Value             = 0;
                    dbHandle.con.Open();
                    UserRegistercmd.ExecuteNonQuery();
                    Session["otp"] = null;
                    dbHandle.con.Close();
                    ViewBag.error = "Company Registration Sucess";

                    Mail.SendMail(Register.email, "Your User Name and Password ", "User Name :" + Register.username + "Paassword :" + Register.password);
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(RedirectToAction("Error_View", "CompanyRegister"));
            }
            finally
            {
                Dispose();
            }
            return(RedirectToAction("LoginUser", "UserLogin"));
        }
示例#30
0
        public IEnumerable <Messages> GetAllMessages()
        {
            List <Messages> messages = new List <Messages>();

            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();

                using (SqlCommand Notificationcommand = new SqlCommand("[dbo].[USPNotificationSelect]", dbHandle.con))
                {
                    dbHandle.con.Open();

                    Notificationcommand.Notification = null;
                    Notificationcommand.CommandType  = CommandType.StoredProcedure;
                    Notificationcommand.Parameters.Add("@NotificationToId", SqlDbType.Int).Value = Session["userid"];
                    Notificationcommand.ExecuteNonQuery();
                    SqlDependency dependency = new SqlDependency(Notificationcommand);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

                    if (dbHandle.con.State == ConnectionState.Closed)
                    {
                        dbHandle.con.Open();
                    }

                    SqlDataReader reader = Notificationcommand.ExecuteReader();

                    while (reader.Read())
                    {
                        messages.Add(item:
                                     new Messages
                        {
                            userId           = (int)reader["NotificationToId"],
                            postId           = (int)reader["PostId"],
                            viewedBy         = (string)reader["NotificationBy"],
                            notificationType = (string)reader["NotificationType"],
                            notificationId   = (int)reader["NotificationId"],
                        });
                    }

                    dbHandle.con.Close();
                    return(messages);
                }
            }
            catch (Exception e)
            {
                ViewBag.error = "Error!!";
                ExceptionLog.Log(e, Request.UserHostAddress);
            }
            finally
            {
                Dispose();
            }
            return(messages);
        }