public JsonResult User_deActivate(string idTodeActive)
        {
            PDBC db = new PDBC();
            uint id = 0;

            if (UInt32.TryParse(idTodeActive, out id))
            {
                List <ExcParameters> parss = new List <ExcParameters>();
                ExcParameters        par   = new ExcParameters()
                {
                    _KEY   = "@id_PT",
                    _VALUE = idTodeActive
                };
                parss.Add(par);
                db.Connect();
                string result = db.Script("UPDATE [tbl_Customer_Main] SET [C_ISActivate] = 0 WHERE id_Customer= @id_PT", parss);

                db.DC();
                if (result == "1")
                {
                    var ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX106",
                        Errormessage = $"این مشتری با موفقیت غیر فعال شد!",
                        Errortype    = "Success"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                    var           ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX115",
                        Errormessage = $"عدم توانایی در ثبت اطلاعات!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, "sher o ver e L326");
                var           ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"عدم توانایی در ثبت اطلاعات!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
        public ActionResult UploaderPAge()
        {
            ErrorReporterModel er = new ErrorReporterModel()
            {
                ErrorID = "0"
            };

            if (TempData["returnData"] != null)
            {
                er = (ErrorReporterModel)TempData["returnData"];
            }
            return(View(er));
        }
Пример #3
0
        public JsonResult DeleteFromBasket(string idp)
        {
            var ModelSender = new ErrorReporterModel();
            var coockie2    = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket());

            if (coockie2 != null)
            {
                var coockie3 = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value);
                var KK       = coockie3.Items.Find(x => x.idmpc == idp);
                if (KK != null)
                {
                    coockie3.Items.Remove(KK);
                    var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());
                    userCookieIDV.Value   = JsonConvert.SerializeObject(coockie3);
                    userCookieIDV.Expires = DateTime.Now.AddDays(2);
                    Response.SetCookie(userCookieIDV);
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX106",
                        Errormessage = $"با موفقیت حذف شد!",
                        Errortype    = "Success"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX567313",
                        Errormessage = $"این کالا در سبد خرید موجود نمیباشد!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX567313",
                    Errormessage = $"سبد خرید خالیست!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
        public JsonResult GetVaredeAndSadere(ProductInStockpileModelView SenderObj)
        {
            if (ModelState.IsValid)
            {
                if (SenderObj != null)
                {
                    int id_Mpc = 0;
                    if (Int32.TryParse(SenderObj.InOutStructures.id_Mpc, out id_Mpc))
                    {
                        string id_CreatedByAdmin = "0";
                        if (Session["AdministratorRegistery"] != null)
                        {
                            id_CreatedByAdmin = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                        }
                        else
                        {
                            var           coockie          = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                            Administrator administratorobj = CoockieController.SayMyName(coockie.Value);
                            id_CreatedByAdmin = administratorobj.id_Admin;
                        }
                        PDBC db = new PDBC();
                        db.Connect();
                        using (DataTable dt = db.Select("SELECT [id_PQT] ,[PriceModule] FROM [tlb_Product_MainProductConnector] WHERE [id_MPC] = " + id_Mpc))
                        {
                            using (DataTable dtStockpile = db.Select("SELECT [id_Stockpile]  FROM [tbl_Modules_StockpileMainTable] WHERE [id_MPC] = " + id_Mpc))
                            {
                                db.DC();
                                if (dtStockpile.Rows.Count > 0)
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        List <ExcParameters> allpars = new List <ExcParameters>();
                                        ExcParameters        par     = new ExcParameters()
                                        {
                                            _KEY   = "@id_TransactionType",
                                            _VALUE = SenderObj.InOutStructures.Whichone
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_Stockpile",
                                            _VALUE = dtStockpile.Rows[0]["id_Stockpile"].ToString()
                                        };
                                        allpars.Add(par);
                                        if (SenderObj.InOutStructures.Whichone == "1")
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@shop_id",
                                                _VALUE = SenderObj.InOutStructures.Shopid1
                                            };
                                            allpars.Add(par);
                                        }
                                        else
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@shop_id",
                                                _VALUE = SenderObj.InOutStructures.shopid2
                                            };
                                            allpars.Add(par);
                                        }
                                        string[]        dates           = SenderObj.InOutStructures.ActionDate.Split('/');
                                        string[]        times           = SenderObj.InOutStructures.Time.Split(':');
                                        PersianDateTime persianDateTime = new PersianDateTime(Convert.ToInt32(dates[0]), Convert.ToInt32(dates[1]), Convert.ToInt32(dates[2]), Convert.ToInt32(times[0]), Convert.ToInt32(times[1]), 0);


                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@StockpileDate_Transaction",
                                            _VALUE = persianDateTime.ToDateTime()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@StockpileTime_Transaction",
                                            _VALUE = SenderObj.InOutStructures.Time
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_PQT",
                                            _VALUE = dt.Rows[0]["id_PQT"].ToString()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@MoneyId",
                                            _VALUE = dt.Rows[0]["PriceModule"].ToString()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@PriceOf_Transaction",
                                            _VALUE = SenderObj.InOutStructures.INOUTPrice
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@PQTValueOf_Transaction",
                                            _VALUE = SenderObj.InOutStructures.INOUTValue
                                        };
                                        allpars.Add(par);
                                        if (!string.IsNullOrEmpty(SenderObj.InOutStructures.Description))
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@Description_Transaction",
                                                _VALUE = SenderObj.InOutStructures.Description
                                            };
                                            allpars.Add(par);
                                        }
                                        else
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@Description_Transaction",
                                                _VALUE = ""
                                            };
                                            allpars.Add(par);
                                        }
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_SubmiterAdmin",
                                            _VALUE = id_CreatedByAdmin
                                        };
                                        allpars.Add(par);


                                        db.Connect();
                                        string result = db.Script("INSERT INTO [tbl_Modules_StockpileTransactionMainTable]([id_TransactionType],[id_Stockpile],[shop_id],[StockpileDate_Transaction],[StockpileTime_Transaction],[id_PQT],[MoneyId],[PriceOf_Transaction],[PQTValueOf_Transaction],[Description_Transaction],[id_SubmiterAdmin]) VALUES(@id_TransactionType,@id_Stockpile,@shop_id,@StockpileDate_Transaction,@StockpileTime_Transaction,@id_PQT,@MoneyId,@PriceOf_Transaction,@PQTValueOf_Transaction,@Description_Transaction,@id_SubmiterAdmin)", allpars);
                                        db.DC();
                                        if (result == "1")
                                        {
                                            var ModelSender = new ErrorReporterModel
                                            {
                                                ErrorID      = "SX1645605",
                                                Errormessage = $"اطلاعات با موفقیت ثبت شد!",
                                                Errortype    = "Success"
                                            };
                                            return(Json(ModelSender));
                                        }
                                        else
                                        {
                                            PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, "IN Controller : {AdministratorStockpileController}\nMethod : {public JsonResult GetVarede(ProductInStockpileModelView senderObj)  Script : INSERT INTO [tbl_Modules_StockpileTransactionMainTable]([id_TransactionType],[id_Stockpile],[shop_id],[Submitdate_Transaction],[StockpileDate_Transaction],[StockpileTime_Transaction],[id_PQT],[MoneyId],[PriceOf_Transaction],[PQTValueOf_Transaction],[Description_Transaction],[id_SubmiterAdmin]) VALUES(@id_TransactionType,@id_Stockpile,@shop_id,@Submitdate_Transaction,@StockpileDate_Transaction,@StockpileTime_Transaction,@id_PQT,@MoneyId,@PriceOf_Transaction,@PQTValueOf_Transaction,@Description_Transaction,@id_SubmiterAdmin) ||| Result :" + result);
                                            var           ModelSender = new ErrorReporterModel
                                            {
                                                ErrorID      = "EX1186781",
                                                Errormessage = $"عدم توانایی در ثبت اطلاعات",
                                                Errortype    = "Error"
                                            };
                                            return(Json(ModelSender));
                                        }
                                    }
                                    else
                                    {
                                        var ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "EX645756697",
                                            Errormessage = $"محصول مورد نظر یافت نشد",
                                            Errortype    = "Error"
                                        };
                                        return(Json(ModelSender));
                                    }
                                }
                                else
                                {
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX645697",
                                        Errormessage = $"محصول مورد نظر یافت نشد",
                                        Errortype    = "Error"
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                        }
                    }
                    else
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX1897",
                            Errormessage = $"اطلاعات وارده خلاف متغیر های قانونی میباشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }
                else
                {
                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, "IN Controller : {AdministratorStockpileController}\nMethod : {public JsonResult GetVarede(ProductInStockpileModelView senderObj)  (senderObj == null)");
                    var           ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX111",
                        Errormessage = $"ورود متغیر خلاف پروتکل های امنیتی",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                //foreach (ModelError error in ModelState.Values.)
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("InOutStructures.", "InOutStructures_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }



            return(Json(""));
        }
        public JsonResult LoginAuth(string mobile, string password)
        {
            var ModelSender = new ErrorReporterModel();

            if (string.IsNullOrEmpty(mobile))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا شماره موبایل خودرا وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            if (string.IsNullOrEmpty(password))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا کلمه عبور را وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            EncDec dn = new EncDec();

            password = dn.HMACMD5Generator(password);
            PDBC db = new PDBC();
            List <ExcParameters> pars = new List <ExcParameters>();
            ExcParameters        par  = new ExcParameters()
            {
                _KEY   = "@Mobile",
                _VALUE = mobile
            };

            pars.Add(par);
            par = new ExcParameters()
            {
                _KEY   = "@PASS",
                _VALUE = password
            };
            pars.Add(par);
            db.Connect();
            DataTable dt = db.Select("SELECT [id_Customer] ,[C_Mobile] ,[C_FirstName] ,[C_LastNAme] FROM [tbl_Customer_Main] WHERE [C_Mobile] = @Mobile AND [C_Password] LIKE @PASS AND [C_ISActivate] = 1", pars);

            db.DC();
            if (dt.Rows.Count == 1)
            {
                tbl_Customer_Main tcm = new tbl_Customer_Main()
                {
                    id_Customer = dt.Rows[0]["id_Customer"].ToString(),
                    C_FirstName = dt.Rows[0]["C_FirstName"].ToString(),
                    C_LastNAme  = dt.Rows[0]["C_LastNAme"].ToString(),
                    C_Mobile    = dt.Rows[0]["C_Mobile"].ToString()
                };
                try
                {
                    var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerCode());
                    userCookieIDV.Value   = CoockieController.SetCustomerAUTHCookie(tcm);
                    userCookieIDV.Expires = DateTime.Now.AddDays(2);
                    Response.SetCookie(userCookieIDV);
                }
                catch (Exception coockieEXception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth)
                    {
                        EXOBJ = coockieEXception
                    };
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1075463",
                        Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }

                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت وارد شدید!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"کاربری با این مشخصات یافت نشد!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
        public ActionResult Index(ChangeProfileModel adObj1)
        {
            Administrator adObj = adObj1.administrator;

            if (ModelState.IsValid)
            {
                string adminID = "";
                try
                {
                    adminID = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                }
                catch (Exception exception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = exception
                    };
                }
                //If Session Doesent work
                try
                {
                    HttpCookie cookie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                    adminID = CoockieController.SayMyName(cookie.Value).id_Admin;
                }
                catch (Exception EX)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = EX
                    };
                }
                if (string.IsNullOrEmpty(adminID))
                {
                    adminID = "NO-ID";
                }

                PDBC db = new PDBC();
                List <ExcParameters> dbparams = new List <ExcParameters>();
                adObj.ad_avatarprofile = "/AdminDesignResource/app/media/img/users/100_12.jpg";
                ExcParameters param = new ExcParameters()
                {
                    _VALUE = adminID,
                    _KEY   = "@id_Admin"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_firstname,
                    _KEY   = "@ad_firstname"
                };
                dbparams.Add(param);

                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_lastname,
                    _KEY   = "@ad_lastname"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_avatarprofile,
                    _KEY   = "@ad_avatarprofile"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_email,
                    _KEY   = "@ad_email"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_phone,
                    _KEY   = "@ad_phone"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_mobile,
                    _KEY   = "@ad_mobile"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_NickName,
                    _KEY   = "@ad_NickName"
                };
                dbparams.Add(param);

                db.Connect();
                string result = db.Script(
                    "UPDATE [tbl_ADMIN_main] SET [ad_firstname] = @ad_firstname ,[ad_lastname] = @ad_lastname ,[ad_avatarprofile] = @ad_avatarprofile ,[ad_email] = @ad_email ,[ad_phone] = @ad_phone ,[ad_mobile] = @ad_mobile ,[ad_NickName] = @ad_NickName WHERE id_Admin=@id_Admin",
                    dbparams);
                db.DC();
                if (result == "1")
                {
                    try
                    {
                        var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                        sessionChanger.ad_avatarprofile   = adObj.ad_avatarprofile;
                        sessionChanger.ad_NickName        = adObj.ad_NickName;
                        sessionChanger.ad_firstname       = adObj.ad_firstname;
                        sessionChanger.ad_lastname        = adObj.ad_lastname;
                        sessionChanger.ad_email           = adObj.ad_email;
                        sessionChanger.ad_phone           = adObj.ad_phone;
                        sessionChanger.ad_mobile          = adObj.ad_mobile;
                        Session["AdministratorRegistery"] = sessionChanger;
                    }
                    catch (Exception EX)
                    {
                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                        {
                            EXOBJ = EX
                        };
                    }
                    try
                    {
                        HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                        var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                        sessionChanger.ad_avatarprofile = adObj.ad_avatarprofile;
                        sessionChanger.ad_NickName      = adObj.ad_NickName;
                        sessionChanger.ad_firstname     = adObj.ad_firstname;
                        sessionChanger.ad_lastname      = adObj.ad_lastname;
                        sessionChanger.ad_email         = adObj.ad_email;
                        sessionChanger.ad_phone         = adObj.ad_phone;
                        sessionChanger.ad_mobile        = adObj.ad_mobile;
                        var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                        userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                        userCookieIDV.Expires = DateTime.Now.AddYears(5);
                        Response.SetCookie(userCookieIDV);
                    }
                    catch (Exception EX)
                    {
                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                        {
                            EXOBJ = EX
                        };
                    }

                    var ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX101",
                        Errormessage = "اطلاعات کاربری با موفقیت ویرایش شد!",
                        Errortype    = "Success"
                    };

                    return(Json(ModelSender));
                }
                else
                {
                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                    var           ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX103",
                        Errormessage = $"عدم توانایی در ویرایش اطلاعات با پشتیبانی تماس حاصل فرمایید! کد پیگیری برای شما :{rep.CodeGenerated}",
                        Errortype    = "Error"
                    };
                    ViewBag.EXLogin = ModelSender;
                    return(Json(ModelSender));
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                //foreach (ModelError error in ModelState.Values.)
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("administrator.", "administrator_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX104",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }
        }
        public ActionResult ChangeAuthInformations(ChangeProfileModel informations)
        {
            changeAuthInformation information = informations.authInformation;

            if (ModelState.IsValid)
            {
                string adminID = "";
                try
                {
                    adminID = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                }
                catch (Exception exception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = exception
                    };
                }
                //If Session Doesent work
                try
                {
                    HttpCookie cookie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                    adminID = CoockieController.SayMyName(cookie.Value).id_Admin;
                }
                catch (Exception EX)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = EX
                    };
                }
                if (string.IsNullOrEmpty(adminID))
                {
                    adminID = "NO-ID";
                }
                PDBC db = new PDBC();
                List <ExcParameters> dbparams = new List <ExcParameters>();
                ExcParameters        param    = new ExcParameters()
                {
                    _VALUE = adminID,
                    _KEY   = "@id_Admin"
                };
                dbparams.Add(param);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [ad_password] FROM [tbl_ADMIN_main] WHERE [id_Admin] = @id_Admin", dbparams))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        EncDec en             = new EncDec();
                        string md5GeneratedPW = en.HMACMD5Generator(information.OLDpassword);
                        if (md5GeneratedPW == dt.Rows[0]["ad_password"].ToString())
                        {
                            if (string.IsNullOrEmpty(information.Newpassword1))
                            {
                                param = new ExcParameters()
                                {
                                    _VALUE = information.Username,
                                    _KEY   = "@ad_username"
                                };
                                dbparams.Add(param);
                                db.Connect();
                                string result = db.Script("UPDATE [tbl_ADMIN_main] SET [ad_username] = @ad_username WHERE [id_Admin] = @id_Admin", dbparams);
                                db.DC();
                                if (result == "1")
                                {
                                    try
                                    {
                                        var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                                        sessionChanger.Username           = information.Username;
                                        Session["AdministratorRegistery"] = sessionChanger;
                                    }
                                    catch (Exception EX)
                                    {
                                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 298)}")
                                        {
                                            EXOBJ = EX
                                        };
                                    }
                                    try
                                    {
                                        HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                                        var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                                        sessionChanger.Username = information.Username;
                                        var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                                        userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                                        userCookieIDV.Expires = DateTime.Now.AddYears(5);
                                        Response.SetCookie(userCookieIDV);
                                    }
                                    catch (Exception EX)
                                    {
                                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 315)}")
                                        {
                                            EXOBJ = EX
                                        };
                                    }
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "SX102",
                                        Errormessage = "نام کاربری با موفقیت ویرایش شد!",
                                        Errortype    = "Success"
                                    };
                                    return(Json(ModelSender));
                                }
                                else
                                {
                                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                                    var           ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX108",
                                        Errormessage = "عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید",
                                        Errortype    = "Error"
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                            else
                            {
                                if (information.Newpassword1 == information.Newpassword2)
                                {
                                    param = new ExcParameters()
                                    {
                                        _VALUE = information.Username,
                                        _KEY   = "@ad_username"
                                    };
                                    dbparams.Add(param);
                                    param = new ExcParameters()
                                    {
                                        _VALUE = md5GeneratedPW,
                                        _KEY   = "@ad_password"
                                    };
                                    dbparams.Add(param);
                                    db.Connect();
                                    string result = db.Script("UPDATE  [tbl_ADMIN_main] SET [ad_password] = @ad_password,[ad_username] = @ad_username  WHERE [id_Admin] = @id_Admin", dbparams);
                                    db.DC();
                                    if (result == "1")
                                    {
                                        try
                                        {
                                            var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                                            sessionChanger.Username           = information.Username;
                                            Session["AdministratorRegistery"] = sessionChanger;
                                        }
                                        catch (Exception EX)
                                        {
                                            PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                                            {
                                                EXOBJ = EX
                                            };
                                        }
                                        try
                                        {
                                            HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                                            var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                                            sessionChanger.Username = information.Username;
                                            var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                                            userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                                            userCookieIDV.Expires = DateTime.Now.AddYears(5);
                                            Response.SetCookie(userCookieIDV);
                                        }
                                        catch (Exception EX)
                                        {
                                            PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                                            {
                                                EXOBJ = EX
                                            };
                                        }


                                        var ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "SX103",
                                            Errormessage = "اطلاعات ورود با موفقیت ویرایش شد!",
                                            Errortype    = "Success"
                                        };
                                        return(Json(ModelSender));
                                    }
                                    else
                                    {
                                        PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                                        var           ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "EX110",
                                            Errormessage = $"عدم توانایی در ویرایش اطلاعات با پشتیبانی تماس حاصل فرمایید! کد پیگیری برای شما :{rep.CodeGenerated}",
                                            Errortype    = "Error"
                                        };
                                        return(Json(ModelSender));
                                    }
                                }
                                else
                                {
                                    List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                                    ModelErrorReporter        er        = new ModelErrorReporter()
                                    {
                                        IdOfProperty = "authInformation_Newpassword1",
                                        ErrorMessage = "عدم یکسانی کلمه های عبور"
                                    };
                                    allErrors.Add(er);
                                    er = new ModelErrorReporter()
                                    {
                                        IdOfProperty = "authInformation_Newpassword2",
                                        ErrorMessage = "عدم یکسانی کلمه های عبور"
                                    };
                                    allErrors.Add(er);
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX109",
                                        Errormessage = "عدم یکسانی کلمه های عبور",
                                        Errortype    = "ErrorWithList",
                                        AllErrors    = allErrors
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                        }
                        else
                        {
                            List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                            ModelErrorReporter        er        = new ModelErrorReporter()
                            {
                                IdOfProperty = "authInformation_OLDpassword",
                                ErrorMessage = "کلمه عبور بدرستی وارد نشده است"
                            };
                            allErrors.Add(er);
                            var ModelSender = new ErrorReporterModel
                            {
                                ErrorID      = "EX105",
                                Errormessage = $"کلمه عبور حال شما کلید شما برای ایجاد تغییرات میباشد",
                                Errortype    = "ErrorWithList",
                                AllErrors    = allErrors
                            };
                            return(Json(ModelSender));
                        }
                    }
                    else
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX107",
                            Errormessage = $"کاربر یافت نشد با پشتیبانی تماس بفرمایید",
                            Errortype    = "Error",
                        };
                        return(Json(ModelSender));
                    }
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("authInformation.", "authInformation_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX106",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }
        }
Пример #8
0
        public JsonResult AddproductToBasket(string idp, string Number_inp)
        {
            var ModelSender = new ErrorReporterModel();

            if (string.IsNullOrEmpty(Number_inp) || Convert.ToInt32(Number_inp) < 1)
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX186763",
                    Errormessage = $"تعداد محصول خریداری شده معتبر نمیباشد!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            PDBC db = new PDBC();

            tbl_Customer_Main tcm = new tbl_Customer_Main();
            var coockie           = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX186763",
                    Errormessage = $"ابتدا وارد اکانت کاربری خود شوید!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            var coockie2 = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket());

            if (coockie2 != null)
            {
                var coockie3 = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value);
                var KK       = coockie3.Items.Find(x => x.idmpc == idp);
                if (KK != null)
                {
                    coockie3.Items.Remove(KK);
                }
                List <ExcParameters> pars = new List <ExcParameters>();
                ExcParameters        par  = new ExcParameters()
                {
                    _KEY   = "@id_MPC",
                    _VALUE = idp
                };
                pars.Add(par);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [Quantity],[Title] ,[PriceXquantity] ,[PricePerquantity] ,[MultyPriceStartFromQ] ,[MultyPrice] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = @id_MPC AND [tlb_Product_MainProductConnector_ISDELETE] = 0 ", pars))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        ShoppingBasketItems ssd = new ShoppingBasketItems()
                        {
                            idmpc     = idp,
                            CountOf   = Convert.ToInt32(Number_inp),
                            ImagePath = UploaderGeneral.imageFinderfromIDMPC(idp, ImageSizeEnums.Thumbnail),
                            Title     = dt.Rows[0]["Title"].ToString()
                        };
                        int assd = Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString());
                        if (Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()) < Convert.ToInt32(Number_inp))
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                        }
                        else
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                        }
                        ssd.Totals = ssd.PriceXQ * ssd.CountOf;
                        coockie3.Items.Add(ssd);
                    }
                    else
                    {
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX567763",
                            Errormessage = $"محصول یافت نشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }



                var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());
                userCookieIDV.Value   = JsonConvert.SerializeObject(coockie3);
                userCookieIDV.Expires = DateTime.Now.AddDays(2);
                Response.SetCookie(userCookieIDV);
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت افزوده شد!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            else
            {
                ShoppingBasket SB = new ShoppingBasket()
                {
                    Items = new List <ShoppingBasketItems>()
                };
                List <ExcParameters> pars = new List <ExcParameters>();
                ExcParameters        par  = new ExcParameters()
                {
                    _KEY   = "@id_MPC",
                    _VALUE = idp
                };
                pars.Add(par);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [Quantity] ,[Title],[PriceXquantity] ,[PricePerquantity]   ,[MultyPriceStartFromQ] ,[MultyPrice] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = @id_MPC AND [tlb_Product_MainProductConnector_ISDELETE] = 0 ", pars))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        ShoppingBasketItems ssd = new ShoppingBasketItems()
                        {
                            idmpc     = idp,
                            CountOf   = Convert.ToInt32(Number_inp),
                            ImagePath = UploaderGeneral.imageFinderfromIDMPC(idp, ImageSizeEnums.Thumbnail),
                            Title     = dt.Rows[0]["Title"].ToString()
                        };
                        if (Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()) < Convert.ToInt32(Number_inp))
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                        }
                        else
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                        }
                        ssd.Totals = ssd.PriceXQ * ssd.CountOf;
                        SB.Items.Add(ssd);
                    }
                    else
                    {
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX567763",
                            Errormessage = $"محصول یافت نشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }
                var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());
                userCookieIDV.Value   = JsonConvert.SerializeObject(SB);
                userCookieIDV.Expires = DateTime.Now.AddDays(2);
                Response.SetCookie(userCookieIDV);
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت افزوده شد!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
        }
Пример #9
0
        public JsonResult SubmitFactor(string ABC)
        {
            var  ModelSender         = new ErrorReporterModel();
            PDBC db                  = new PDBC();
            List <ExcParameters> pas = new List <ExcParameters>();
            tbl_Customer_Main    tcm = new tbl_Customer_Main();
            var coockie              = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            tcm = CoockieController.SayWhoIsHE(coockie.Value);
            FactorPopUpModel fpm       = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
            string           DeleteAns = "خرید با موفقیت انجام شد!";
            var c = new HttpCookie(ProjectProperies.CustomerShoppingFactor());

            c.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(c);
            var d = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());

            d.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(d);
            AmountOfProductsLeft itemRemains = new AmountOfProductsLeft();

            for (int i = 0; i < fpm.items.Count; i++)
            {
                if (itemRemains.CanBuyThisProductFromThisShop(fpm.items[i].Id.ToString(), "1", fpm.items[i].number) <= 0)
                {
                    DeleteAns = "متاسفانه موجودی برخی کالا ها برای خرید شما کافی نمیباشد ";
                    fpm.items.RemoveAt(i);
                }
            }
            if (fpm.items.Count == 0)
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX-fa3432",
                    Errormessage = DeleteAns,
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            Int64 totals = 0;

            for (int i = 0; i < fpm.items.Count; i++)
            {
                totals += fpm.items[i].total;
            }
            fpm.totality = totals.ToString();
            ExcParameters pa = new ExcParameters()
            {
                _KEY   = "@id_Customer",
                _VALUE = tcm.id_Customer
            };

            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_Code",
                _VALUE = "FM-" + DateTime.Now.Ticks
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_Price",
                _VALUE = fpm.totality
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_PaymentCode",
                _VALUE = "FMpc-" + DateTime.Now.Ticks
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_CreatorID",
                _VALUE = tcm.id_Customer
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@id_CAddress",
                _VALUE = "4003"
            };
            pas.Add(pa);
            db.Connect();
            string ReturnedID = db.Script("INSERT INTO [tbl_Factor_Main]([id_Customer],[MainFactor_Code],[MainFactor_Price],[MainFactor_IsPay],[MainFactor_PayMessage],[MainFactor_PaymentCode],[MainFactor_Tax],[MainFactor_TotalOff],[MainFactor_CreatedByUserType],[MainFactor_CreatorID],[MainFactor_ISEDITED],[MainFactor_EditedByAdminID],[MainFactor_EditedTo_id_MainFactor],[MainFactor_IsDeleted],[MainFactor_IsReturnedMoney],[MainFactor_PayType],[ChildFactor_DeleteTypeID],[id_CAddress]) output inserted.[id_MainFactor]     VALUES(@id_Customer ,@MainFactor_Code ,@MainFactor_Price ,1,N'NOMessage',@MainFactor_PaymentCode,0,0,2,@MainFactor_CreatorID ,0,0,0,0,0,1,0,@id_CAddress )", pas);

            db.DC();
            int idmf = 0;

            if (Int32.TryParse(ReturnedID, out idmf))
            {
                string flag = "";
                pas = new List <ExcParameters>();
                string res = "";
                db.Connect();
                for (int i = 0; i < fpm.items.Count; i++)
                {
                    pa = new ExcParameters()
                    {
                        _KEY   = "@id_MainFactor",
                        _VALUE = ReturnedID
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_CreatorID",
                        _VALUE = tcm.id_Customer
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_ProductID",
                        _VALUE = fpm.items[i].Id
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_PurePrice",
                        _VALUE = fpm.items[i].total
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_PurePricee",
                        _VALUE = fpm.items[i].total
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_QBuy",
                        _VALUE = fpm.items[i].number
                    };
                    pas.Add(pa);

                    string idd = db.Script("INSERT INTO [tbl_Factor_ChildFactor]([id_MainFactor],[ChildFactor_DeleteTypeID],[ChildFactor_DeletedByAdminID],[ChildFactor_ISDELETED],[ChildFactor_CreateDate],[ChildFactor_CreatedByUserTypeID],[ChildFactor_CreatorID],[ChildFactor_ProductModuleType],[ChildFactor_ProductID],[ChildFactor_PastProductHistoryID],[ChildFactor_HasOff],[ChildFactor_OffID],[ChildFactor_OffCode],[ChildFactor_OffPrice],[ChildFactor_PurePrice],[ChildFactor_PriceAfterOff],[ChildFactor_ProductReturnTypeID],[ChildFactor_ISCERTIFIED],[ChildFactor_ISEDITED],[ChildFactor_EditedByAdminID],[ChildFactor_EditedTo_id_ChildFactor],[ChildFactor_QBuy]) OUTPUT inserted.[id_ChildFactor] VALUES(@id_MainFactor,0,0,0,GETDATE(),2,@ChildFactor_CreatorID ,1,@ChildFactor_ProductID ,0,0,0,N' ',0,@ChildFactor_PurePrice ,@ChildFactor_PurePricee,0,1,0,0,0,@ChildFactor_QBuy )", pas);

                    res  += db.Script("INSERT INTO  [tbl_Factor_FactorInStock]([id_ChildFactor],[FactorInStock_FirstShopID],[FactorInStock_SecondShopID],[FactorInStock_CreatedDate],[FactorInStock_TransActionByAdminID],[FactorInStock_HasTransAction]) VALUES(" + idd + " ,1 ,0,GETDATE(),0,0)");
                    flag += "1";
                }
                db.DC();
                if (flag == res)
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX-fa3432",
                        Errormessage = DeleteAns,
                        Errortype    = "Success"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX15779455",
                        Errormessage = $"خرید انجام نشد!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX785673455",
                    Errormessage = $"خرید انجام نشد!!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
Пример #10
0
        public JsonResult ProductCountCalc(string QCount, string idmpc)
        {
            PDBC db = new PDBC();

            db.Connect();
            using (DataTable dt = db.Select("SELECT [Title],[MCName] ,[SCName],[PriceXquantity],[MultyPrice],[MultyPriceStartFromQ]  FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = " + idmpc))
            {
                db.DC();
                var ModelSender = new ErrorReporterModel();
                if (dt.Rows.Count == 0)
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1153455",
                        Errormessage = $"محصول یافت نشد!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    if (Convert.ToInt32(QCount) > Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()))
                    {
                        FactorPopUpModel fpm = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            if (fpm.items[i].Id == Convert.ToInt32(idmpc))
                            {
                                fpm.items[i].PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                                fpm.items[i].number  = Convert.ToInt32(QCount);
                                fpm.items[i].total   = fpm.items[i].PriceXQ * fpm.items[i].number;
                                break;
                            }
                        }
                        Int64 totality = 0;
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            totality += fpm.items[i].total;
                        }
                        fpm.totality = totality.ToString();
                        ModelSender  = new ErrorReporterModel
                        {
                            ErrorID      = dt.Rows[0]["MultyPrice"].ToString(),
                            Errormessage = $"",
                            Errortype    = "Success"
                        };
                        var userCookieIDV = new HttpCookie(ProjectProperies.CustomerShoppingFactor());
                        userCookieIDV.Value   = CoockieController.SetCustomerShopFactorCookie(fpm);
                        userCookieIDV.Expires = DateTime.Now.AddDays(2);
                        Response.SetCookie(userCookieIDV);
                        return(Json(ModelSender));
                    }
                    else
                    {
                        FactorPopUpModel fpm = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            if (fpm.items[i].Id == Convert.ToInt32(idmpc))
                            {
                                fpm.items[i].PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                                fpm.items[i].number  = Convert.ToInt32(QCount);
                                fpm.items[i].total   = fpm.items[i].PriceXQ * fpm.items[i].number;
                                break;
                            }
                        }
                        Int64 totality = 0;
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            totality += fpm.items[i].total;
                        }
                        fpm.totality = totality.ToString();

                        var userCookieIDV = new HttpCookie(ProjectProperies.CustomerShoppingFactor());
                        userCookieIDV.Value   = CoockieController.SetCustomerShopFactorCookie(fpm);
                        userCookieIDV.Expires = DateTime.Now.AddDays(2);
                        Response.SetCookie(userCookieIDV);
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = dt.Rows[0]["PriceXquantity"].ToString(),
                            Errormessage = $"",
                            Errortype    = "Success"
                        };
                        return(Json(ModelSender));
                    }
                }
            }
        }
        public JsonResult UploadImages(ImageInGalleryModel SenderObj)
        {
            var ss = Request.Files;

            if (ModelState.IsValid)
            {
                List <string> Skips;
                if (!string.IsNullOrEmpty(SenderObj.SkipImageIDS))
                {
                    Skips = SenderObj.SkipImageIDS.Trim(',').Split(',').ToList();
                }
                else
                {
                    Skips = new List <string>();
                }
                int SkipimagesCount             = Skips.Count;
                int imagescount                 = Request.Files.Count;
                List <HttpPostedFileBase> newss = new List <HttpPostedFileBase>();
                for (int i = 0; i < imagescount; i++)
                {
                    bool Skipper = false;
                    for (int j = 0; j < SkipimagesCount; j++)
                    {
                        if (i.ToString() == Skips[j])
                        {
                            Skipper = true;
                        }
                    }
                    if (Skipper)
                    {
                        continue;
                    }
                    newss.Add(Request.Files[i]);
                }
                Skips = null;
                if (newss.Count > 0)
                {
                    ImageUploader uploadAll = new ImageUploader();
                    string        res       = uploadAll.UploadImages(new ImageInGalleryModel()
                    {
                        ImageName        = SenderObj.ImageName,
                        ImageDescription = SenderObj.ImageDescription,
                        ImageAlt         = SenderObj.ImageAlt
                    }, newss);
                    if (res == "1")
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "SX10100Upload",
                            Errormessage = "تمامی عکس ها با موفقیت بارگزاری شده اند!",
                            Errortype    = "Success"
                        };
                        TempData["returnData"] = ModelSender;
                        return(Json(ModelSender));
                    }
                    else if (res == "-1")
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX10200Upload",
                            Errormessage = "قبلا عکسی با این نام ذخیره شده است!",
                            Errortype    = "Error"
                        };
                        TempData["returnData"] = ModelSender;
                        return(Json(ModelSender));
                    }
                    else
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX1020Upload",
                            Errormessage = "عدم توانایی در بارگزاری فایل ها با پشتیبانی در تماس باشید!",
                            Errortype    = "Error"
                        };
                        TempData["returnData"] = ModelSender;

                        return(Json(ModelSender));
                    }
                }
                else
                {
                    var ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1020Upload",
                        Errormessage = "هیچ عکسی یافت نشد !",
                        Errortype    = "Error"
                    };
                    TempData["returnData"] = ModelSender;
                    return(Json(ModelSender));
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                //foreach (ModelError error in ModelState.Values.)
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i],
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                TempData["returnData"] = ModelSender;
                return(Json(ModelSender));
            }
        }
Пример #12
0
 public ActionResult LoginAuth(LoginAuthForm adObj)
 {
     if (ModelState.IsValid)
     {
         EncDec dn = new EncDec();
         adObj.Password = dn.HMACMD5Generator(adObj.Password);
         PDBC db = new PDBC();
         List <ExcParameters> parasms    = new List <ExcParameters>();
         ExcParameters        parameters = new ExcParameters()
         {
             _KEY   = "@username",
             _VALUE = adObj.Username
         };
         parasms.Add(parameters);
         parameters = new ExcParameters()
         {
             _KEY   = "@password",
             _VALUE = adObj.Password
         };
         parasms.Add(parameters);
         db.Connect();
         using (DataTable dt = db.Select("SELECT * FROM [tbl_ADMIN_main] WHERE ad_username LIKE @username AND ad_password LIKE @password", parasms))
         {
             db.DC();
             int dtrowcount = dt.Rows.Count;
             if (dtrowcount > 0)
             {
                 if (dt.Rows[0]["ad_isActive"].ToString() == "1")
                 {
                     Administrator AdminSession = new Administrator()
                     {
                         id_Admin = dt.Rows[0]["id_Admin"].ToString()
                         ,
                         ad_typeID = dt.Rows[0]["ad_typeID"].ToString()
                         ,
                         ad_firstname = dt.Rows[0]["ad_firstname"].ToString()
                         ,
                         ad_lastname = dt.Rows[0]["ad_lastname"].ToString()
                         ,
                         ad_avatarprofile = dt.Rows[0]["ad_avatarprofile"].ToString()
                         ,
                         ad_email = dt.Rows[0]["ad_email"].ToString()
                         ,
                         ad_phone = dt.Rows[0]["ad_phone"].ToString()
                         ,
                         ad_mobile = dt.Rows[0]["ad_mobile"].ToString()
                         ,
                         ad_has2stepSecurity = dt.Rows[0]["ad_has2stepSecurity"].ToString()
                         ,
                         ad_isActive = dt.Rows[0]["ad_isActive"].ToString()
                         ,
                         ad_isDelete = dt.Rows[0]["ad_isDelete"].ToString()
                         ,
                         ad_lastseen = dt.Rows[0]["ad_lastseen"].ToString()
                         ,
                         ad_lastlogin = dt.Rows[0]["ad_lastlogin"].ToString()
                         ,
                         ad_loginIP = dt.Rows[0]["ad_loginIP"].ToString()
                         ,
                         ad_regdate = dt.Rows[0]["ad_regdate"].ToString()
                         ,
                         ad_personalColorHexa = dt.Rows[0]["ad_personalColorHexa"].ToString()
                         ,
                         AdminModeID = dt.Rows[0]["AdminModeID"].ToString()
                         ,
                         ad_NickName = dt.Rows[0]["ad_NickName"].ToString(),
                         Username    = adObj.Username
                     };
                     try
                     {
                         Session["AdministratorRegistery"] = AdminSession;
                         try
                         {
                             var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                             userCookieIDV.Value   = CoockieController.SetCoockie(AdminSession);;
                             userCookieIDV.Expires = DateTime.Now.AddYears(5);
                             Response.SetCookie(userCookieIDV);
                         }
                         catch (Exception coockieEXception)
                         {
                             PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth)
                             {
                                 EXOBJ = coockieEXception
                             };
                             var ModelSender = new ErrorReporterModel
                             {
                                 ErrorID      = "EX103",
                                 Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                                 Errortype    = "Error"
                             };
                             ViewBag.EXLogin = ModelSender;
                             return(View("Index"));
                         }
                         if (string.IsNullOrEmpty(adObj.urlRedirection))
                         {
                             return(RedirectToAction("Logs", "AdminLoginAuth"));
                         }
                         else
                         {
                             string[] GotToPage      = adObj.urlRedirection.Split('-');
                             string   actionname     = "";
                             string   controllername = "";
                             for (int i = 0; i < 2; i++)
                             {
                                 if (GotToPage[i].Contains("A_"))
                                 {
                                     actionname = GotToPage[i].Replace("A_", "");
                                 }
                                 else
                                 {
                                     controllername = GotToPage[i];
                                 }
                             }
                             return(RedirectToAction(actionname, controllername));
                         }
                     }
                     catch (Exception SessionException)
                     {
                         PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth)
                         {
                             EXOBJ = SessionException
                         };
                         var ModelSender = new ErrorReporterModel
                         {
                             ErrorID      = "EX103",
                             Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                             Errortype    = "Error"
                         };
                         ViewBag.EXLogin = ModelSender;
                         return(View("Index"));
                     }
                 }
                 else
                 {
                     var ModelSender = new ErrorReporterModel
                     {
                         ErrorID      = "EX101",
                         Errormessage = "کاربر پیدا شده در وضعیت غیر فعال میباشد و اجازه دسترسی به پنل را نخواهد داشت",
                         Errortype    = "Error"
                     };
                     ViewBag.EXLogin = ModelSender;
                     return(View("Index"));
                 }
             }
             else
             {
                 var ModelSender = new ErrorReporterModel
                 {
                     ErrorID      = "EX102",
                     Errormessage = "کاربری با این مشخصات یافت نشد!",
                     Errortype    = "Error"
                 };
                 ViewBag.EXLogin = ModelSender;
                 return(View("Index"));
             }
         }
         db.DC();
         return(View("Index"));
     }
     else
     {
         var ModelSender = new ErrorReporterModel
         {
             ErrorID      = "EX100",
             Errormessage = "درخواست ارسال شده مطابق با ساختار امنیتی نمیباشد",
             Errortype    = "Error"
         };
         ViewBag.EXLogin = ModelSender;
         return(View("Index"));
     }
 }