Ejemplo n.º 1
0
        /// <summary>
        /// اعتبارسنجی کاربر
        /// </summary>
        /// <returns>شناسه کاربر</returns>
        protected int validateUser()
        {
            int id = 0;

            try { id = int.Parse(Request.Headers.GetValues("UserId").FirstOrDefault()); }
            catch
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            string unicKey = "";

            try { unicKey = Request.Headers.GetValues("UnicKey").FirstOrDefault(); }
            catch
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            var user = new B_Users().GetUsers(id);

            if (user == null)
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            if (user.UnicKey != unicKey)
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            return(id);
        }
Ejemplo n.º 2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _USession _session = new _USession();
            B_Users   objU     = new B_Users();

            if (_session.User_Id != "" || _session.User_Group != "")
            {
                if (!objU.checkAuthorization(_session.User_Group, Function_Id))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
                    {
                        { "controller", "Home" },
                        { "action", "Error" }
                    });
                }
            }
            else
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "controller", "Home" },
                    { "action", "Login" }
                });
            }
            base.OnActionExecuting(filterContext);
        }
Ejemplo n.º 3
0
        public ActionResult Modify(M_Users User)
        {
            object result = "";

            try
            {
                B_Users bUser   = new B_Users();
                var     oldUser = bUser.GetUsers(User.Id);
                if (oldUser.ImageName.ToLower() != "default.jpg" && oldUser.ImageName.ToLower() != User.ImageName)
                {
                    System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Profile") + "/" + oldUser.ImageName);
                }
                bUser.Edit(User);
                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 4
0
        public JsonResult GetUserList(int limit = 10, int offset = 1, string user_name = "", string mobile = "")
        {
            B_Users      b_user = new B_Users();
            List <Order> order  = new List <Order>()
            {
                Order.Desc("id")
            };

            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "user_name", value = user_name, searchType = Common.EnumBase.SearchType.Like
                },
                new SearchTemplate()
                {
                    key = "mobile", value = mobile, searchType = Common.EnumBase.SearchType.Like
                },
                new SearchTemplate()
                {
                    key = "", value = new int[] { offset, limit }, searchType = Common.EnumBase.SearchType.Paging
                }
            };
            var list_user = b_user.GetList(st, order);

            var total = b_user.GetCount(st);

            return(Json(new { total = total, rows = list_user }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// اعتبارسنجی کاربر یا پرسنل
        /// </summary>
        /// <returns>شناسه کاربر اهراز شده و نوع آن</returns>
        protected Tuple <int, MFValidationUserRole> validateUserOrPersonel()
        {
            int id = 0;

            try { id = int.Parse(Request.Headers.GetValues("UserId").FirstOrDefault()); }
            catch
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            string unicKey = "";

            try { unicKey = Request.Headers.GetValues("UnicKey").FirstOrDefault(); }
            catch
            {
                throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }

            var user = new B_Users().GetUsers(id);

            if (user != null && user.UnicKey == unicKey)
            {
                return(Tuple.Create(id, MFValidationUserRole.USER));
            }
            var personel = new B_Personels().GetPersonels(unicKey, id);

            if (personel != null)
            {
                return(Tuple.Create(id, MFValidationUserRole.PERSONEL));
            }
            throw F_ExeptionFactory.MakeExeption("کاربر مورد نظر در سیستم وجود ندارد",
                                                 ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserId", Enums.Loging.E_LogType.SYSTEM_ERROR);
        }
Ejemplo n.º 6
0
        public JsonResult GetUser(int id)
        {
            DAO.BLL.B_Users b_user = new B_Users();
            var             res    = b_user.GetUser(id);

            return(Json(res));
        }
Ejemplo n.º 7
0
        public ActionResult Index()
        {
            var users = new B_Users().GetUsers(1, "", "", "");

            foreach (var li in users)
            {
                li.LastRequest = new B_ServicesRequests().GetLastRequestDateByUserId(li.Id);
            }
            return(View(users));
        }
Ejemplo n.º 8
0
        public ActionResult Deleted()
        {
            ViewBag.Route = new List <MFRoute>
            {
                new MFRoute {
                    ActionName = "Index", ControllerName = "Users", Title = "لیست کاربران", Priority = 1
                }
            };
            B_Users bPersonel = new B_Users();

            return(View(bPersonel.GetDeletedUsers()));
        }
Ejemplo n.º 9
0
        public ActionResult ResetPasswordSendVerificationCode(string PhoneNumber)
        {
            object result = "";

            try
            {
                if (string.IsNullOrEmpty(PhoneNumber))
                {
                    throw F_ExeptionFactory.MakeExeption("شماره تلفن وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (PhoneNumber.Length != 11)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره تلفن وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                var user = new B_Users().GetUsers(PhoneNumber);
                if (user == null)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره تلفن وارد شده در سیستم ثبت نشده است",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (user.IsDeleted == true)
                {
                    throw F_ExeptionFactory.MakeExeption("چنین کاربری یافت نشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "User", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                int code = new B_SmsAuthorise().AddCode(PhoneNumber);
                if (code != 0)
                {
                    new ApplicationHelper.Sms().SendSms(PhoneNumber, code.ToString());
                    result = new B_SmsAuthorise().GetSmsDetailsId(PhoneNumber);
                }
                else
                {
                    throw F_ExeptionFactory.MakeExeption("متاسفانه کد فعال سازی ارسال نشد. مجددا تلاش کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "VerificationCode", E_LogType.SYSTEM_ERROR);
                }
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_USER_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 10
0
        public bool LoginUser(int Id, string UnicKey)
        {
            var users = new B_Users().GetUsers(Id, UnicKey);

            if (users == null)
            {
                return(false);
            }
            var finalUser = B_PublicFunctions.GenericMaper <M_Users, V_Users>(new List <M_Users> {
                users
            }).FirstOrDefault();

            finalUser.ConnectionId = Context.ConnectionId;
            Users.Add(finalUser);
            return(true);
        }
Ejemplo n.º 11
0
        public ActionResult GetPeymentDetails(int PayId)
        {
            object result = "";

            try
            {
                var peymentReuest = new B_UserPayment().GetPaymentById(PayId);
                var payTypes      = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_TYPE);
                var payStatus     = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_STATUS);

                var account = new B_Accounts().GetAccounts(peymentReuest.AccountId);

                var user = new B_Users().GetUsers(peymentReuest.UserId);
                result = new
                {
                    Payment = new
                    {
                        Point      = peymentReuest.Point,
                        CreateDate = peymentReuest.CreateDate.ConvertToPesianDateName(true),
                        EditDate   = peymentReuest.ModifyDate.ConvertToPesianDateName(true),
                        Status     = payStatus.Where(c => c.Id == (int)peymentReuest.Status).FirstOrDefault().Title,
                        StatusCode = (int)peymentReuest.Status,
                        Message    = peymentReuest.Message,
                        Type       = payTypes.Where(c => c.Id == (int)peymentReuest.Type).FirstOrDefault().Title
                    },
                    AccountInfo = new
                    {
                        Shaba           = account == null ? "---" : account.ShabaNumber,
                        PayAccountOwner = account == null ? "---" : account.AccountHolderName,
                        BankName        = account == null ? "---" : account.BankName
                    },
                    User = new { Name = user.FirstName + " " + user.LastName, RegisterDate = user.RegisterDate.ConvertToPesianDateName(true), Tell = user.MobileNumber, Image = user.ImageName }
                };
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 12
0
        public ActionResult Modify(int Id)
        {
            ViewBag.Route = new List <MFRoute>
            {
                new MFRoute {
                    ActionName = "Index", ControllerName = "Users", Title = "لیست کاربران", Priority = 1
                }
            };
            B_Users bUser = new B_Users();
            var     user  = bUser.GetUsers(Id);

            if (user == null || user.Id == CurrentUser.Id)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.AnistetoType = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.INSTITUTE_TYPE);
            return(View(user));
        }
Ejemplo n.º 13
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.Request.Cookies[MFCookies.END_USER_KEY] != null)
            {
                string  key  = filterContext.HttpContext.Request.Cookies[MFCookies.END_USER_KEY].Value;
                M_Users user = null;
                B_Users ub   = new B_Users();
                try
                {
                    user = ub.GetUsersByToken(key);
                }
                catch { }

                if (user != null)
                {
                    return;
                }
            }
            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", area = "User" }));
            filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
        }
Ejemplo n.º 14
0
        public ActionResult GetUser(int PageNumber, string Name, string Family, string Mobile)
        {
            object result = "";

            try
            {
                result = new B_Users().GetUsers(PageNumber, Name, Family, Mobile);
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 15
0
        public ActionResult ChangeState(E_PublicCategory.PAYMENT_STATUS Status, int PayId)
        {
            object result = "";

            try
            {
                var peyment = new B_UserPayment().ChangeState(Status, PayId);
                var user    = new B_Users().GetUsers(peyment.UserId);
                if (Status == E_PublicCategory.PAYMENT_STATUS.FAILED)
                {
                    new B_ServicesRequestItems().Add(new Models.M_ServicesRequestItems
                    {
                        CreateDate   = DateTime.Now,
                        ImageName    = "Default.png",
                        RequestId    = 0,
                        ScorePerUnit = 1,
                        Title        = "بازگشت امتیاز به دلیل لغو درخواست برداشت امتیاز به شماره " + peyment.Id,
                        Unit         = "امتیاز",
                        UserType     = peyment.UserType,
                        Value        = peyment.Point,
                        UserId       = user.Id
                    });
                }
                result = true;
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 16
0
        public ActionResult Add(M_Users Personel)
        {
            object result = "";

            try
            {
                var buser = new B_Users();
                buser.Add(Personel);
                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 17
0
        public ActionResult Login(string PhoneNumber, string Password)
        {
            object result = "";

            try
            {
                PhoneNumber = B_PublicFunctions.ReplacePersianNums(PhoneNumber);
                Password    = B_PublicFunctions.ReplacePersianNums(Password);
                if (string.IsNullOrEmpty(PhoneNumber))
                {
                    throw F_ExeptionFactory.MakeExeption("نام کاربری را وارد کنید",
                                                         ((int)E_ErrorCodes.USERNAME_OR_PASSWORD) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserName", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(Password))
                {
                    throw F_ExeptionFactory.MakeExeption("گذرواژه را وارد کنید",
                                                         ((int)E_ErrorCodes.USERNAME_OR_PASSWORD) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Password", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (PhoneNumber.Length != 11)
                {
                    throw F_ExeptionFactory.MakeExeption("گذرواژه وارد شده صحیح نمیباشد",
                                                         ((int)E_ErrorCodes.USERNAME_OR_PASSWORD) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Password", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                var user = new B_Users().GetUsers(PhoneNumber);
                if (user == null)
                {
                    throw F_ExeptionFactory.MakeExeption("چنین کاربری یافت نشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "User", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (user.IsDeleted == true)
                {
                    throw F_ExeptionFactory.MakeExeption("چنین کاربری یافت نشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "User", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (user.Password == Password && user.IsActive == false)
                {
                    B_SmsAuthorise bSms = new B_SmsAuthorise();
                    var            code = bSms.AddCode(PhoneNumber);
                    new ApplicationHelper.Sms().SendSms(PhoneNumber, code.ToString());
                    result = new { IsActive = false, SmsId = bSms.GetSmsDetailsId(PhoneNumber), UserId = user.Id };
                }
                else if (user.Password == Password && user.IsActive)
                {
                    result = new { IsActive = true, SmsId = 0, UserId = user.Id }
                }
                ;
                else
                {
                    throw F_ExeptionFactory.MakeExeption("نام کاربری یا گذرواژه صحیح نمیباشد",
                                                         ((int)E_ErrorCodes.USERNAME_OR_PASSWORD) + S_Seprators.ErrorFieldNameSeprator.ToString() + "UserNameOrPassword", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }

                HttpCookie Coki = new HttpCookie(MFCookies.END_USER_KEY);
                Coki.Value   = user.UnicKey.ToString();
                Coki.Expires = DateTime.Now.AddYears(1);
                Response.Cookies.Add(Coki);
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_USER_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 18
0
        public ActionResult GetUserPointDetails(int UserId)
        {
            object result = "";

            try
            {
                var    peymentReuest       = new B_UserPayment().GetPayment(UserId);
                var    peymentRequestItems = new B_ServicesRequestItems().GetItem(UserId, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER);
                var    res = new List <DetaildPointModel>();
                double pointPay = 0, pointRecive = 0;
                var    payStatus = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_STATUS);
                var    payType   = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_TYPE);

                foreach (var li in peymentReuest)
                {
                    res.Add(new DetaildPointModel
                    {
                        Title    = payType.Where(c => c.Id == (int)li.Type).FirstOrDefault().Title,
                        Date     = li.CreateDate.ConvertToPesianDateName(true),
                        Time     = li.CreateDate.Hour + ":" + li.CreateDate.Minute + ":" + li.CreateDate.Second,
                        Score    = (li.Point * -1).ToString(),
                        Status   = payStatus.Where(c => c.Id == (int)li.Status).FirstOrDefault().Title,
                        RealDate = li.CreateDate
                    });
                    if (li.Status != E_PublicCategory.PAYMENT_STATUS.FAILED)
                    {
                        pointPay += li.Point * -1;
                    }
                }

                foreach (var li in peymentRequestItems)
                {
                    res.Add(new DetaildPointModel
                    {
                        Title    = li.Title,
                        Date     = li.CreateDate.ConvertToPesianDateName(true),
                        Time     = li.CreateDate.Hour + ":" + li.CreateDate.Minute + ":" + li.CreateDate.Second,
                        Score    = ((li.Value.HasValue ? li.Value.Value : 0) * li.ScorePerUnit).ToString(),
                        Status   = "ثبت شده",
                        RealDate = li.CreateDate
                    });
                    pointRecive += (li.Value.HasValue ? li.Value.Value : 0) * li.ScorePerUnit;
                }

                var user = new B_Users().GetUsers(UserId);
                result = new
                {
                    PointSummery = new { PointPay = pointPay, PointRecive = pointRecive, PointTotal = pointRecive + pointPay },
                    PointDetails = res.OrderByDescending(c => c.RealDate).ToList(),
                    User         = new { Name = user.FirstName + " " + user.LastName, RegisterDate = user.RegisterDate.ConvertToPesianDateName(true), Tell = user.MobileNumber }
                };
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Ejemplo n.º 19
0
        public ActionResult Register(string Name, string Family, int InstituteType, string MobileNumber, string AsignCode, string Password)
        {
            object result = "";

            try
            {
                MobileNumber = B_PublicFunctions.ReplacePersianNums(MobileNumber);
                AsignCode    = B_PublicFunctions.ReplacePersianNums(AsignCode);
                Password     = B_PublicFunctions.ReplacePersianNums(Password);
                if (string.IsNullOrEmpty(Name))
                {
                    throw F_ExeptionFactory.MakeExeption("لطفا نام را وارد کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Name", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(Family))
                {
                    throw F_ExeptionFactory.MakeExeption("لطفا نام خانوادگی را وارد کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Family", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(MobileNumber))
                {
                    throw F_ExeptionFactory.MakeExeption("لطفا شماره تلفن همراه را وارد کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "MobileNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(Name))
                {
                    throw F_ExeptionFactory.MakeExeption("لطفا گذرواژه را وارد کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Password", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (!B_PublicFunctions.IsValidPhone(MobileNumber, true))
                {
                    throw F_ExeptionFactory.MakeExeption("شماره تلفن همراه وارد شده صحیح نمیباشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "MobileNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                M_Users mUser = new M_Users();
                mUser.FirstName     = Name;
                mUser.LastName      = Family;
                mUser.InstituteType = (E_PublicCategory.INSTITUTE_TYPE)InstituteType;
                mUser.MobileNumber  = MobileNumber;
                mUser.ReagentCode   = string.IsNullOrEmpty(AsignCode) ? 0 : int.Parse(AsignCode);
                mUser.RegisterDate  = DateTime.Now;
                mUser.LastOnline    = DateTime.Now;
                mUser.IsActive      = false;
                mUser.IsDeleted     = false;
                mUser.UnicKey       = Guid.NewGuid().ToString();
                mUser.Password      = Password;
                mUser.UserType      = E_PublicCategory.USER_TYPE.HOME_STORE;
                mUser.ReagentUserId = string.IsNullOrEmpty(AsignCode) ? null : (int?)(new B_Users().GetUserByReagentCode(int.Parse(AsignCode)).Id);
                var res = new B_Users().Add(mUser);

                if (mUser.ReagentUserId.HasValue)
                {
                    new B_ServicesRequestItems().Add(new M_ServicesRequestItems {
                        CategoryId         = 0,
                        CreateDate         = DateTime.Now,
                        ImageName          = "Default.jpg",
                        IsFailed           = false,
                        RequestId          = -5001,
                        ScorePerUnit       = 200,
                        ScorePerUnitDriver = 200,
                        Title    = $"معرفی {mUser.FirstName} {mUser.LastName} به سیستم",
                        Unit     = "عدد",
                        UserType = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER,
                        Value    = 1,
                        UserId   = mUser.ReagentUserId.Value
                    });
                }

                B_SmsAuthorise bSms = new B_SmsAuthorise();
                var            code = bSms.AddCode(MobileNumber);
                new ApplicationHelper.Sms().SendSms(MobileNumber, code.ToString());
                result = bSms.GetSmsDetailsId(MobileNumber);
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_USER_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }