Example #1
0
        public string EditDetails(User u)
        {
            bool isProceed = false;

            try
            {
                using (driver)
                {
                    using (var session = driver.Session())
                    {
                        var mobilecmd = "match (n:User{Mobile:'"
                                        + u.MobileNumber + "'}) return n.UserId as UserId";
                        var emailcmd = "match (n:User{Email:'"
                                       + u.Email + "'}) return n.UserId as UserId";
                        var mobResponse   = session.Run(mobilecmd);
                        var emailResponse = session.Run(emailcmd);
                        try
                        {
                            var value = mobResponse.Single().Values["UserId"].ToString();
                            if (value == u.UserId)
                            {
                                isProceed = true;
                            }
                            else
                            {
                                isProceed = false;
                                return("Mobile number already taken. Please try with another number.");
                            }
                        }
                        catch
                        {
                            isProceed = true;
                        }
                        try
                        {
                            var value = emailResponse.Single().Values["UserId"].ToString();
                            if (value == u.UserId)
                            {
                                isProceed = true;
                            }
                            else
                            {
                                isProceed = false; return("Email address already taken. Please try with another email address.");
                            }
                        }
                        catch
                        {
                            isProceed = true;
                        }
                        if (isProceed)
                        {
                            var cmd = "match (n:User{UserId:'" + u.UserId + "'}) " +
                                      "set n.Age='" + u.Age + "', n.PinCode='" + u.PinCode + "'," +
                                      "n.FirstName='" + u.FirstName + "'," +
                                      "n.LastName='" + u.LastName + "',n.City='" + u.City + "'," +
                                      "n.Country='" + u.Country + "',n.AreaCode='" + u.AreaCode + "'," +
                                      "n.Password='******',n.Email='" + u.Email + "'," +
                                      "n.Address1='" + u.Address1 + "',n.Address2='" + u.Address2 + "'," +
                                      " n.Mobile = '" + u.MobileNumber + "'";
                            session.Run(cmd);
                            return("true");
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogData.GetFrameDetails(ex, out StackFrame frame, out int line);
                LogData.LogExceptionData(ex.Message, string.IsNullOrEmpty(frame.GetFileName()) ? "" : frame.GetFileName(),
                                         ex.InnerException != null ? ex.InnerException.Message : "No InnerException", line.ToString(), frame.GetMethod().Name);
            } return("false");
        }