Beispiel #1
0
        public int Create(CompanyViewModel model)
        {
            var company = _mapper.Map <tbl_Company>(model);

            _context.tbl_Company.Add(company);
            _context.SaveChanges();
            return(company.Id);
        }
        public bool GiveAccessMenuToUser(int userid)
        {
            foreach (var item in db.tbl_accesstypes)
            {
                if (db.tbl_accesslevels.Where(a => a.userid == userid && a.accessid == item.id).SingleOrDefault() == null)
                {
                    tbl_accesslevels t = new tbl_accesslevels();
                    t.accessid    = item.id;
                    t.accessvalue = false;
                    t.userid      = userid;
                    db.tbl_accesslevels.Add(t);
                }
            }
            db.SaveChanges();
            // default true
            var q2 = db.tbl_accesslevels.Where(a => a.userid == userid && a.accessid == 2).SingleOrDefault();
            var q3 = db.tbl_accesslevels.Where(a => a.userid == userid && a.accessid == 33).SingleOrDefault();

            q2.accessvalue = true;
            q3.accessvalue = true;
            //
            db.SaveChanges();
            return(true);
        }
        public static bool statisticssave(string controller, string action, string ip, Nullable <int> userid)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            tbl_statistics          t  = new tbl_statistics();

            t.actionname     = action;
            t.controllername = controller;
            t.enterdate      = DateTime.Now;
            t.ip             = ip;
            if (userid != null)
            {
                t.user_id = userid;
            }

            db.tbl_statistics.Add(t);
            db.SaveChanges();
            return(true);
        }
        public void settransportaiondetails(int cartid, tbl_transportaiondetails tcartdetails)
        {
            var cart = findcartbyid(cartid);

            if (cart.tbl_transportaiondetails.Count() == 0)
            {
                //add
                db.tbl_transportaiondetails.Add(tcartdetails);
            }
            else
            {
                //Edit
                var tdetails = cart.tbl_transportaiondetails.FirstOrDefault();
                tdetails.location_address = tcartdetails.location_address;
                tdetails.location_address = tcartdetails.location_name;
                tdetails.person_peygiri   = tcartdetails.person_peygiri;
                tdetails.tell             = tcartdetails.tell;
            }
            db.SaveChanges();
        }
Beispiel #5
0
        public void Create(PersonCreateViewModel person)
        {
            tbl_person _person = new tbl_person();

            _person.Fname          = person.FName;
            _person.Lname          = person.LName;
            _person.codemelli      = person.Codemelli;
            _person.Pdescription   = person.Pdescription;
            _person.tell           = person.Tell;
            _person.cell           = person.Cell;
            _person.sex            = person.Sex;
            _person.prefix         = person.Prefix;
            _person.BrancheId      = person.BrancheId;
            _person.CreateDatetime = DateTime.Now;
            foreach (var per in person.PersonAddresses)
            {
                _person.PersonAddresses.Add(new tbl_PersonAddress
                {
                    Address    = per.Address,
                    Phone      = per.Phone,
                    Phone2     = per.Phone2,
                    Phone3     = per.Phone3,
                    PostalCode = per.PostalCode
                });
            }
            foreach (var per in person.PersonInformationSetting)
            {
                _person.PersonInformationSettings.Add(new tbl_PersonInformationSetting()
                {
                    PropertyValue = per.PropertyValue,
                    PropertyName  = per.PropertyName
                });
            }
            _context.tbl_person.Add(_person);
            _context.SaveChanges();
        }
Beispiel #6
0
        public ActionResult orderexporttopdf(int orderid)
        {
            //StimulsoftLicenseHelper.Activate();
            //Stimulsoft.Base.StiActivator

            // step 2: set license key
            //var lic = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHlNHxonFYHbpjDx+27slnZs5ftj9P0vr+YW2Pss00P90qmOB2PRI4SjLhAufUnckk8d8LLVu4bgMi/81ymyeO7J3xLjnveXaZmAwzelnxcpnNxi4aUQulVJFvwK+qiOxltk2avtYSEE8jmq4WkdUTp9xske7sHZRhrGePQV5sn54z+RtcNe6cUUNgTwUc8dglgPK/WFe8jcs9XjzaRp3RM+l4PfDluVrp1RaQNJsb10wa5XZT2xv3nuWlW9OMBsPLc/63Hsm5zhEfIP3P6J0pV9x/P2lHAiXuDGKMbeKntP0fxrqxRGrhelfT9AV1O5eDpofH8TAi9HvDPn6LHKsddVVcRfXq658kn94eQWyZkEwfPQJWgQUmXhPcZbj5ecea/dnruFjI+1Y1sxLbJA2wzzYtCU2NEj0kAfxId97OiRITg7oQZs2IMiaOFJgvDL1hR5uv69OffNFZk6+h2bm8OB9GF/PZuisO+BzM+HQRlPQP8FWo6jd79o03LiCtH6mVOrQfEAhF8r0qeF7y8TV2OJ8hHnve7mXKTXr4KmGkRzzmDmfAMrpfoPFF4HtglInJTHbKYqiH2z1DDpJVUNa0+kn/Y9RzSZLtIRBVNzgUMubsB+CPJWMal80oD9bTW8/I3O7QFgvSGIUgCaFAs3rYlkJ3Obt7AVXexGQUuTph7Z4auM4/V4DDhhvdy+8+PIj1/kAilviTYXWxqhbLfciZOEMHeGCtepilOvgvY7arGeSqv5tUfIPqoyBh6RSczg+Hf0soFq0t7ysW3FyteYsfsbHppN1htRrfcP3fEn89vddsamdUgUBgZJ8nDKZ+4E0d+g3w+Jdegnu7PAjNjd5YKLt85NfBRwktdWGwp7fKvK2NpidjRVXRHi1CYlcDoxeaCqOqW7/vPv668X6omx6EsYOyWiFskWQxm/E7dpA4ixmNOyMgolUMRbqQK1uVIT1xeavP3r3C9Pm5f4pBkzpUxX54pc6Z+T/psyIXfR77C+kVXEt3+TA9TX+jZ7Zi8oSX1ImDJWn9wPFMCl11Gl3vHTYno2cvK2zeM8vasV/Q+C9GRJkXkDEceDLHaFbDiWQaJi4TJex/1sbYS239UhciSOVizEhpdVA1E7D6vPzSJ9TQjgWtrbANDmjpHzK2YiTnvbUKf9FibYLmtl0iJ3WUhzO1R03jDUJSvF030BPxGWUt5UMTSpaImLTboUbWbCkLnkDXPyxT9xZORjgWTQzVYNUmCXW2qEtzOyVbB+m16KzWvFf69QI1zMEo/N6a1JzT7499RnmqkuqPyBESnVvAaG7Qfz8jff5tK6ml+BTsCRX4MsHV/Sh100Tv4Kt3raiWKyBG6L2UVbKvtaFnGSYPJzNSY6ndlrxWC65VSSbeXxR6AzKVjLw9sgJLh9i6IQ5d5cUfEFzFKNWvCPDiEERKPpG2Vj4yR3HoayBrgpRqgaLAq1/V//hlWT/dcRIevJGjDgbZGv2E1KOiB4Llj/HX0HAO7cCZrtM57hf5jMnqGDvkYSOOHTPqMPv9QbLdBX+5RnHoa8xtXPp1vVPbJXZHJ/f9rVOnGCqjtR6pWAGDYOOZkXZ02y0zjow0go2JuCZnzYZw37U12hcrb2gxPAlmy/SQerFJXaySRLSXu0QW1pfw==";
            //StiLicense.Key = lic;
            var order = db.tbl_order.ToList().Where(a => a.id == orderid).Select(g => new
            {
                id                 = g.id.ToString(),
                username           = g.user.username,
                sodoordate         = g.sodoor_date.ToPersianDate(),
                sodoortime         = g.sodoor_date.ToShortTimeString(),
                fullname           = g.orderfor.Fname + " " + g.orderfor.Lname,
                cellphone          = g.orderfor.cell,
                frombranch         = g.from_branch.branch_name,
                tobranch           = g.to_branch.branch_name,
                sharh              = g.sharh,
                done               = (g.done == false ? "نزد " + g.to_branch.branch_name : "تحویل شده"),
                address            = g.orderfor.address,
                frombranch_address = g.from_branch.Address,
                tobranch_address   = g.to_branch.Address
            });


            var orderitems = db.tbl_orderdetails.Where(a => a.order_id == orderid).ToList().Select(g => new
            {
                productid   = g.product_id.ToString(),
                Catgname    = g.product_.category.categoryname,
                productname = g.product_.category.categoryname + "| " + g.product_.name + "| " + g.product_.codename + "| " + g.product_.dimension,
                weight      = g.product_.weight.ToString() + "kg",
                number      = g.number.ToString(),
                totalweight = (g.product_.weight.HasValue ? (g.product_.weight.Value * g.number).ToString() : ""),
                desc        = g.description
            });

            int branch = db.tbl_order.Where(a => a.id == orderid).SingleOrDefault().from_branchid;

            StiReport report     = new StiReport();
            string    webroot    = _hostingEnvironment.WebRootPath;
            string    myroot     = "/Content/reports/Reportorder.mrt";
            string    targetroot = webroot + myroot;

            //report.Load(Path.Combine(_hostingEnvironment.WebRootPath, "/Content/reports/Reportorder.mrt"));
            report.Load(targetroot);
            //report.Load(Path.Combine(_hostingEnvironment.WebRootPath, "/Content/reports/Reportorder.mrt"));
            report.RegData("orderinfo", order);
            report.RegData("orderitems", orderitems);
            report.Render();
            MemoryStream stream = new MemoryStream();


            StiPdfExportService  pdfexport = new StiPdfExportService();
            StiPdfExportSettings st        = new StiPdfExportSettings();

            pdfexport.ExportPdf(report, stream, st);

            stream.Position = 0;


            byte[]          b = stream.ToArray();
            tbl_filestosend t = new tbl_filestosend();

            t.caption        = "حواله " + order.SingleOrDefault().id;
            t.filecontent    = b;
            t.uploaddatetime = DateTime.Now;
            t.imagename      = "order" + order.SingleOrDefault().id + ".pdf";
            t.user_id        = int.Parse(User.Claims.FirstOrDefault().Value);
            t.filecontent    = b;

            db.tbl_filestosend.Add(t);
            db.SaveChanges();
            //
            //var context = GlobalHost.ConnectionManager.GetHubContext<chatHub>();



            string msgframe = "";

            msgframe += "<p class='msgtext'>حواله " + orderid + " جهت آقای " + order.SingleOrDefault().fullname + "</p>";
            msgframe += "<a target='_blank' class='btn btn-success' href='/admin/DownLoadFile/" + t.id + "'>دانلود فایل</a>";
            string mymsgpure    = $"حواله {orderid} جهت آقای {order.SingleOrDefault().fullname}";
            string thisdatetime = order.SingleOrDefault().sodoordate + "  " + order.SingleOrDefault().sodoortime;

            tbl_signalRmsg msg = new tbl_signalRmsg {
                from_userid = int.Parse(User.Claims.FirstOrDefault().Value), msg_text = msgframe, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true, msg_textpure = mymsgpure
            };

            db.tbl_signalRmsg.Add(msg);
            db.SaveChanges();

            _hub.Clients.All.SendAsync("addNewMessage", msg.id, User.Claims.FirstOrDefault().Value, User.Identity.Name, msgframe, thisdatetime, "public", branch);



            return(Json(true));
        }
Beispiel #7
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();

            if (filterContext.HttpContext.Session.GetInt32("userid") == null)
            {
                if (filterContext.HttpContext.Request.Cookies["userid"] != null)
                {
                    filterContext.HttpContext.Session.SetString("username", filterContext.HttpContext.Request.Cookies["username"]);
                    filterContext.HttpContext.Session.SetInt32("userid", int.Parse(filterContext.HttpContext.Request.Cookies["userid"]));

                    int    userid   = filterContext.HttpContext.Session.GetInt32("userid").Value;
                    string fname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().name;
                    string lname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().Lname;
                    string fullname = fname + " " + lname;
                    filterContext.HttpContext.Session.SetString("fullname", fullname);
                }
            }



            tbl_statistics t = new tbl_statistics();

            //t.actionname = (string)routingValues["action"];
            t.actionname     = filterContext.RouteData.Values["Action"].ToString();
            t.controllername = filterContext.RouteData.Values["Controller"].ToString();
            t.enterdate      = DateTime.Now;
            t.ip             = filterContext.HttpContext.Connection.RemoteIpAddress.ToString();
            if (filterContext.HttpContext.Session.GetInt32("userid") == null)
            {
                t.user_id = null;
            }
            else
            {
                t.user_id = filterContext.HttpContext.Session.GetInt32("userid");
            }

            //var myparams = filterContext.ActionParameters;
            var    myparams   = filterContext.ActionArguments;
            string parameters = "";
            int    x          = 0;
            int    count      = 0;

            count = myparams.Count();


            foreach (var item in myparams)
            {
                if (count == 1 || x == count - 1)
                {
                    if (item.Value == null)
                    {
                        parameters = parameters + item.Key + "=null";
                    }
                    else
                    {
                        parameters = parameters + item.Key + "=" + item.Value.ToString();
                    }
                }
                else
                {
                    if (item.Value == null)
                    {
                        parameters = parameters + item.Key + "=null" + "&";
                    }
                    else
                    {
                        parameters = parameters + item.Key + "=" + item.Value.ToString() + "&";
                    }
                }
                x += 1;
            }



            t.parameter = parameters;
            t.fullurl   = "www.soltaniwoodproducts.com/" + t.controllername + "/" + t.actionname + "?" + parameters;
            db.tbl_statistics.Add(t);
            db.SaveChanges();
        }
        public ActionResult sendtext(tbl_contactus t)
        {
            try
            {
                //var q=db.tbl_newscomments .Where(a=> a.newsid == t.newsid ).SingleOrDefault ();

                t.sabtdate = DateTime.Now;
                t.ip       = this.httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();


                db.tbl_contactus.Add(t);

                db.SaveChanges();
                Emailparameter emailp = new Emailparameter();
                emailp.from     = "*****@*****.**";
                emailp.password = "******";
                emailp.smtp     = "smtp.gmail.com";
                emailp.subject  = string.Format("پرسش ثبت شده در سایت از طرف : {0}", t.email);
                emailp.to       = "*****@*****.**";
                string path = Path.Combine(_hostingEnvironment.WebRootPath, "/Content/text/contactus.txt");
                string Body = System.IO.File.ReadAllText(path);

                Body = Body.Replace("t.name", t.name);
                Body = Body.Replace("t.email", t.email);
                Body = Body.Replace("t.ip", t.ip);
                Body = Body.Replace("t.sabtdate", shamsi.ToShamsi(t.sabtdate).ToString());
                Body = Body.Replace("t.text", t.text);

                emailp.text = Body;


                if (Email.send(emailp))
                {
                    TempData["message"] = "متن پرسش شما با موفقیت ارسال گردید";
                    return(RedirectToAction("contactus"));
                }
                else
                {
                    TempData["message"] = "در ارسال پیام خطایی رخ داده است.  لطفاً آدرس ایمیل وارده را مجدداً بررسی فرمایید";
                    return(RedirectToAction("contactus"));
                }
            }
            catch (Exception e)
            {
                TempData["message"] = "در ثبت پرسش شما خطایی رخ داده است. مجدداً تلاش فرمایید";
                return(RedirectToAction("contactus"));
            }
        }
Beispiel #9
0
        public ResultStatus SendSmsWithListPersonId(ArchiveSmsCreateViewModel model)
        {
            var op = new ResultStatus();

            try
            {
                if (model.PersonsId.Any())
                {
                    var person = _context.tbl_person.Where(x => model.PersonsId.Any(y => y == x.id)).ToList();


                    bool isPersian = false;

                    int smsCount = 0;
                    Cls_SMS.ClsSend.FindTxtLanguageAndcount(model.Context, ref isPersian, ref smsCount);
                    var numberOfPersonToSend = 100 / smsCount;
                    int personGroup          = person.Count / numberOfPersonToSend;
                    var remainingPerson      = person.Count % numberOfPersonToSend;

                    int start = 0;
                    for (int i = 0; i < personGroup; i++)
                    {
                        var lst = person.GetRange(start, numberOfPersonToSend);
                        start = numberOfPersonToSend * (i + 1);
                        var result       = _clsSend.SendSMS_Batch(model.Context, lst.Select(x => x.cell).ToArray(), "100008001", "koohi8", "87g5820", "http://193.104.22.14:2055/CPSMSService/Access", "KOOHI", false);
                        var sentMessages = new tbl_sentMessag()
                        {
                            CreateDateTime = DateTime.Now,
                            ContextMessage = model.Context,
                            State          = result[0],
                            RefNumber      = result[1],
                            UserId         = model.UserId
                        };
                        _context.tbl_sentMessag.Add(sentMessages);
                        foreach (var per in lst)
                        {
                            var sentMessagePerson = new tbl_SentMessagPerson()
                            {
                                Person     = per,
                                SentMessag = sentMessages,
                            };
                            _context.tbl_SentMessagPerson.Add(sentMessagePerson);
                        }
                    }


                    if (remainingPerson > 0)
                    {
                        var lst          = person.GetRange(start, remainingPerson);
                        var result       = _clsSend.SendSMS_Batch(model.Context, lst.Select(x => x.cell).ToArray(), "100008001", "koohi8", "87g5820", "http://193.104.22.14:2055/CPSMSService/Access", "KOOHI", false);
                        var sentMessages = new tbl_sentMessag()
                        {
                            CreateDateTime = DateTime.Now,
                            ContextMessage = model.Context,
                            State          = result[0],
                            RefNumber      = result[1],
                            UserId         = model.UserId
                        };
                        _context.tbl_sentMessag.Add(sentMessages);
                        foreach (var per in lst)
                        {
                            var sentMessagePerson = new tbl_SentMessagPerson()
                            {
                                Person     = per,
                                SentMessag = sentMessages,
                            };
                            _context.tbl_SentMessagPerson.Add(sentMessagePerson);
                        }
                    }
                    _context.SaveChanges();
                    op.IsSuccessed = true;
                    op.Message     = "اطلاعات با موفقیت ثبت گردید";
                }
                else
                {
                    op.Message = "اطلاعات را وارد کنید";
                }
            }
            catch (Exception e)
            {
                op.IsSuccessed = false;
                op.Message     = "خطا در عملیات";
            }

            return(op);
        }
Beispiel #10
0
        public ActionResult addnewitem(int product_id = 0)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Json(new cartabstract {
                    number = 0, userid = 0, numberitemexist = 0
                }));
            }
            else
            {
                int user    = _userServices.GetUseridByUsername(User.Identity.Name);
                var product = db.tbl_products.Where(a => a.idproduct == product_id).SingleOrDefault();
                int numberexist;
                var listkala = db.tbl_listkala97.Where(a => a.productid == product_id);
                if (listkala.Count() != 0)
                {
                    numberexist = listkala.Sum(a => a.kalanumberm);
                }
                else
                {
                    numberexist = 0;
                }

                if (numberexist == 0)
                {
                    return(Json(new cartabstract {
                        number = 0, userid = user, numberitemexist = 0
                    }));
                }

                int                      number  = 0;
                cartindropdown           cartabs = new cartindropdown();
                tbl_purchasekartitemlist item    = new tbl_purchasekartitemlist();
                if (db.tbl_purchasekart.Where(a => a.userid == user && a.ispaid == false).Count() == 0)
                {
                    tbl_purchasekart pcart = new tbl_purchasekart();
                    pcart.userid            = user;
                    pcart.purchasedatestart = DateTime.Now;
                    pcart.ispaid            = false;
                    pcart.status            = 0;
                    db.tbl_purchasekart.Add(pcart);
                    db.SaveChanges();


                    item.product_id        = product_id;
                    item.number            = 1;
                    item.price             = 0;
                    item.perchasekart_id   = pcart.id;
                    item.purchase_datetime = DateTime.Now;
                    item.totalprice        = item.number * item.price;
                    db.tbl_purchasekartitemlist.Add(item);
                    db.SaveChanges();

                    number = db.tbl_purchasekartitemlist.Where(a => a.perchasekart_id == pcart.id).Count();
                }
                else
                {
                    var pcartopen = db.tbl_purchasekart.Where(a => a.userid == user && a.ispaid == false).SingleOrDefault();
                    pcartopen.status = 0;
                    int kartidopen = pcartopen.id;
                    if (pcartopen.tbl_purchasekartitemlist.Where(a => a.product_id == product_id).Count() != 0)
                    {
                        return(Json(new { preselected = "1" }));
                    }

                    item.product_id        = product_id;
                    item.number            = 1;
                    item.price             = 0;
                    item.perchasekart_id   = kartidopen;
                    item.purchase_datetime = DateTime.Now;
                    item.totalprice        = item.number * item.price;
                    db.tbl_purchasekartitemlist.Add(item);
                    db.SaveChanges();

                    number = db.tbl_purchasekartitemlist.Where(a => a.perchasekart_id == pcartopen.id).Count();
                }



                cartabs.catgname       = item.product_.category.categoryname;
                cartabs.numberincart   = item.number;
                cartabs.pcode          = item.product_.codename;
                cartabs.pname          = item.product_.name;
                cartabs.productid      = item.product_id;
                cartabs.purchasecartid = item.id;
                cartabs.pimage         = item.product_.thumbnail_image != null ? item.product_.thumbnail_image : new byte[0];
                cartabs.userid         = user;
                //cartabs.totalitemnumberincart = _purchaseCart.itemnumberincart(user);
                return(PartialView("~/Views/Shared/PartialSearchProducts/_PartialItemCart.cshtml", cartabs));
            }
        }
Beispiel #11
0
        public String PaymentAction(int purchasecartid = 0)
        {
            try
            {
                transAction Model = new transAction();
                Model.factorNumber = purchasecartid.ToString();
                // تعیین مقدار قابل پرداخت

                var     cartlist = db.tbl_purchasekartitemlist.Where(a => a.perchasekart_id == purchasecartid);
                decimal totalprice = 0, totalweight = 0, totalcosttransportation = 0, discount = 0;
                string  totalpricestr, totalweightstr, totalcosttransportationstr, discountstr;
                foreach (var item in cartlist)
                {
                    totalprice  = totalprice + (decimal)(item.number * (item.product_.lastcellcost.HasValue == true ? item.product_.lastcellcost.Value : 0));
                    totalweight = totalweight + (decimal)(item.number * (item.product_.weight.HasValue == true ? item.product_.weight.Value : 0));
                }



                totalpricestr = string.Format("{0:#,##0.##}", totalprice) + " ریال";
                if (cartlist.FirstOrDefault().perchasekart_.discount_id != null)
                {
                    discount    = Math.Floor(cartlist.FirstOrDefault().perchasekart_.discount_.percentage.Value *totalprice / 100);
                    discountstr = string.Format("{0:#,##0.##}", discount) + " ریال";
                }
                else
                {
                    discount    = 0;
                    discountstr = string.Format("{0:#,##0.##}", discount) + " ریال";
                }
                if (db.tbl_transportationcost.Where(a => a.cart_id == purchasecartid).Count() > 0)
                {
                    totalcosttransportation    = db.tbl_transportationcost.Where(a => a.cart_id == purchasecartid).Sum(a => a.totaltcost.Value);
                    totalcosttransportationstr = string.Format("{0:#,##0.##}", totalcosttransportation) + " ریال";
                }
                else
                {
                    totalcosttransportation    = 0;
                    totalcosttransportationstr = string.Format("{0:#,##0.##}", totalcosttransportation) + " ریال";
                }
                decimal payableprice    = 0;
                string  payablepricestr = "";

                payableprice    = totalprice + totalcosttransportation - discount;
                payablepricestr = string.Format("{0:#,##0.##}", payableprice) + " ریال";



                //


                Model.amount       = payableprice.ToString();
                Model.factorNumber = cartlist.FirstOrDefault().perchasekart_.id.ToString();



                //

                Payment        ob        = new Payment();
                string         result    = ob.pay(Model.amount);
                JsonParameters Parmeters = JsonConvert.DeserializeObject <JsonParameters>(result);

                if (Parmeters.status == 1)
                {
                    var thiscart = db.tbl_purchasekart.Where(a => a.id == purchasecartid).SingleOrDefault();
                    thiscart.transId = Parmeters.transId;
                    db.SaveChanges();
                    Response.Redirect("https://pay.ir/payment/gateway/" + Parmeters.transId);
                }
                else
                {
                    return("کدخطا : " + Parmeters.errorCode + "<br />" + "پیغام خطا : " + Parmeters.errorMessage);
                }
                return("");
            }
            catch (Exception exp)
            {
                return("خطا در اتصال به درگاه پرداخت" + exp.Message);
            }
        }
        public ActionResult registerAction([FromForm] RegisterViewModel R, IFormFile image)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { message = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage).ToList(), status = "validationerror" }));
            }
            try
            {
                tbl_user t = new tbl_user();

                if (image != null)
                {
                    if (image.Length > 2097152)
                    {
                        return(Json(new JsonResults {
                            jsonmessage = "حجم تصویر بیش از 2 مگابایت است", jsonstatus = "Error"
                        }));
                    }
                    if (image.ContentType != "image/jpeg")
                    {
                        return(Json(new JsonResults {
                            jsonmessage = "فرمت تصویر باید JPG باشد", jsonstatus = "Error"
                        }));
                    }
                    t.img = saveimageinsql.perform(image, true, 256, 256);
                }
                t.password    = R.password;
                t.signupdate  = DateTime.Now;
                t.status      = false;
                t.Tokenstring = NameGenerator.GenerateUniqCode();
                Random rd = new Random();
                t.uniqkey     = rd.Next(100, 10000);
                t.username    = R.username;
                t.confirmpass = R.confirmpass;
                t.Access      = 2;
                t.email       = R.email;
                t.cellphone   = R.cellphone;
                db.tbl_user.Add(t);
                db.SaveChanges();
                tbl_user user = db.tbl_user.SingleOrDefault(a => a.id == t.id);
                // ارسال ایمیل فعال سازی

                Emailparameter emailp = new Emailparameter();
                emailp.from     = "*****@*****.**";
                emailp.password = "******";
                emailp.smtp     = "smtp.gmail.com";
                emailp.subject  = "ایمیل فعال سازی حساب کاربری";
                emailp.to       = t.email;
                string body = _viewRender.RenderToStringAsync("_ActiveEmail", user);
                emailp.text = body;


                if (Email.send(emailp) == true)
                {
                    return(Json(new JsonResults {
                        jsonmessage = "نام کاربری شما با موفقیت ثبت شد. برای فعال سازی به ایمیل خود مراجعه فرمایید و بر روی لینک فعالسازی کلیک نمایید", jsonstatus = "SuccessRegisterEmail"
                    }));
                    //return Json(true);
                }
                else
                {
                    return(Json(new JsonResults {
                        jsonmessage = "نام کاربری شما با موفقیت ثبت شد. ایمیل مورد نظر فعال یا معتبر نمی باشد. لذا خواهشمند است جهت فعال سازی حساب کاربری خود نام کاربری خود را به شماره 09177017801 پیامک نمایید", jsonstatus = "SuccessRegisterFailEmail"
                    }));
                }
            }
            catch (Exception e)
            {
                return(Json(new JsonResults {
                    jsonmessage = e.Message, jsonstatus = "Exception"
                }));
            }
        }
Beispiel #13
0
        public async Task sendmessage(int from_userid, int?to_userid, string message, string messagetextpure)
        {
            string thisdatetime = DateTime.Now.ToPersianDate() + "  " + DateTime.Now.ToString("HH:mm:ss");
            string status       = "";
            string url          = "";

            if (message.Contains("www.") || message.Contains(".com") || message.Contains(".org") || message.Contains(".net") || message.Contains(".ir"))
            {
                if (message.Contains("http://") || message.Contains("https://"))
                {
                    url     = message;
                    message = "<a href='" + url + "'>" + message + "</a>";
                }
                else
                {
                    url     = "//" + message;
                    message = "<a href='" + url + "'>" + message + "</a>";
                }
            }



            var from_user = db.tbl_signalrUsers.Where(a => a.userid == from_userid).SingleOrDefault();
            int branch    = from_user.user.branches_id.HasValue ? from_user.user.branches_id.Value : 0;

            if (to_userid == null)
            {
                status = "public";
                tbl_signalRmsg msg = new tbl_signalRmsg {
                    from_userid = from_userid, msg_text = message, msg_textpure = messagetextpure, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true
                };
                db.tbl_signalRmsg.Add(msg);
                db.SaveChanges();
                await Clients.All.SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure);
            }
            else
            {
                status = "single";
                var            to_user = db.tbl_signalrUsers.Where(a => a.userid == to_userid.Value).SingleOrDefault();
                tbl_signalRmsg msg     = new tbl_signalRmsg {
                    from_userid = from_userid, to_userid = to_userid, msg_text = message, msg_textpure = messagetextpure, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true
                };
                db.tbl_signalRmsg.Add(msg);
                db.SaveChanges();

                if (to_user.connectionId != null)
                {
                    await Clients.Client(to_user.connectionId).SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure);
                }
                if (to_user.connectionId != from_user.connectionId)
                {
                    await Clients.Client(from_user.connectionId).SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure);
                }
            }
        }