コード例 #1
0
        public ActionResult ProcessShoppingCart(ShoppingCartObject cart, string subdomain)
        {
            try
            {
                if (cart == null || !cart.ShopingCartItemObjects.Any())
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }

                var store = new SessionHelpers().GetStoreInfo(subdomain);
                if (store == null || store.StoreId < 1)
                {
                    return(Json(new StoreItemStockObject(), JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(cart.CustomerIpAddress))
                {
                    cart.CustomerIpAddress = ClientIpHelper.GetClientIpAddress(Request);
                }

                cart.DateInitiated = DateTime.Now;
                var processStatus = new DefaultServices().ProcessShoppingCart(cart);

                return(Json(processStatus, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new StoreItemStockObject(), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="mobile"></param>
        private string SendCode(string mobile, ValidateCodeType type)
        {
            var code = StringHelper.RandNum(6);

            _validateCodeRepository.Add(new Tbl_ValidateCode
            {
                ClientIp     = ClientIpHelper.GetInnerIp(),
                ValidateCode = code,
                Mobile       = mobile,
                TypeId       = (int)type,
                DataStatus   = false,
                CreateTime   = DateTime.Now
            });
            return(code);
        }
コード例 #3
0
        public ActionResult GetClientCartByClientIp(string ip, string subdomain)
        {
            if (string.IsNullOrEmpty(ip))
            {
                ip = ClientIpHelper.GetClientIpAddress(Request);
            }

            var store = new SessionHelpers().GetStoreInfo(subdomain);

            if (store == null || store.StoreId < 1)
            {
                return(Json(new ShoppingCartObject(), JsonRequestBehavior.AllowGet));
            }

            var shoppingCartObject = new DefaultServices().GetShoppingCart(ip);

            return(Json(shoppingCartObject, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public ActionResult GetAddressesByIp(string ip, string subdomain)
        {
            if (string.IsNullOrEmpty(ip))
            {
                ip = ClientIpHelper.GetClientIpAddress(Request);
            }

            if (string.IsNullOrEmpty(ip))
            {
                return(Json(new List <DeliveryAddressObject>(), JsonRequestBehavior.AllowGet));
            }

            var store = new SessionHelpers().GetStoreInfo(subdomain);

            if (store == null || store.StoreId < 1)
            {
                return(Json(new List <DeliveryAddressObject>(), JsonRequestBehavior.AllowGet));
            }

            var addresses = new DefaultServices().GetCustomerPreviousAddresses(ip);

            return(Json(addresses, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public ActionResult AddThroughPutByDepotOwner(ThroughPutObject throughPut)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPut == null)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPut.Quantity < 1)
                {
                    gVal.Error = "Please provide Quantity.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(throughPut.TempPath))
                {
                    gVal.Error = "Document processing failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var path = MoveFile(importerInfo.Id, throughPut.TempPath);
                if (string.IsNullOrEmpty(path))
                {
                    gVal.Error = "Document processing failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip  = ClientIpHelper.GetClientIpAddress(Request);
                var doc = new DocumentObject
                {
                    ImporterId     = importerInfo.Id,
                    DateUploaded   = DateTime.Now,
                    UploadedById   = importerInfo.UserProfileObject.Id,
                    DocumentPath   = path,
                    DocumentTypeId = (int)SpecialDocsEnum.Throughput_agreement,
                    Status         = (int)AppStatus.Pending,
                    IpAddress      = ip
                };

                throughPut.DocumentObject = doc;
                throughPut.IPAddress      = ip;
                var docStatus = new ThroughPutServices().AddThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Error = "Process failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = docStatus;
                gVal.Path  = path.Replace("~", string.Empty);
                gVal.Error = "Throughput information was successfully processed.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }

            catch (Exception)
            {
                gVal.Error = "ThroughPut processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public ActionResult EditThroughPut(HttpPostedFileBase file, long throughPutId, long documentId, double quantity)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPutId < 1 || quantity < 1)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var doc = new DocumentServices().GetDocument(documentId);
                if (doc.DocumentId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Document could not be processed. Please try again.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip   = ClientIpHelper.GetClientIpAddress(Request);
                var path = "";
                if (file != null && file.ContentLength > 0)
                {
                    path = SaveFile2(doc.DocumentPath, file, importerInfo.Id);
                    if (string.IsNullOrEmpty(path))
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Document Could not be processed.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    doc.DocumentPath = path;
                    doc.UploadedById = importerInfo.UserProfileObject.Id;
                    doc.IpAddress    = ip;
                    doc.Status       = (int)AppStatus.Pending;
                    doc.DateUploaded = DateTime.Now;
                    doc.IpAddress    = ip;
                }

                var throughPut = new ThroughPutObject {
                    DocumentObject = doc, IPAddress = ip, Id = throughPutId, Quantity = quantity
                };

                var docStatus = new ThroughPutServices().UpdateThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "ThroughPut information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code              = docStatus;
                gVal.Error             = path;
                Session["_throughPut"] = null;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "ThroughPut information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #7
0
        public ActionResult AddThroughPutByApplicant(HttpPostedFileBase file, long throughPutId, double quantity)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (throughPutId < 1 || quantity < 1)
                {
                    gVal.Error = "Invalid process call.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                var path = SaveFile2("", file, importerInfo.Id);

                if (string.IsNullOrEmpty(path))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Document information Could not be saved.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var ip  = ClientIpHelper.GetClientIpAddress(Request);
                var doc = new DocumentObject
                {
                    DateUploaded   = DateTime.Now,
                    UploadedById   = importerInfo.UserProfileObject.Id,
                    DocumentPath   = path,
                    DocumentTypeId = (int)SpecialDocsEnum.Throughput_agreement,
                    Status         = (int)AppStatus.Pending,
                    ImporterId     = importerInfo.Id,
                    IpAddress      = ip
                };

                var throughPut = new ThroughPutObject {
                    DocumentObject = doc, IPAddress = ip, Id = throughPutId, Quantity = quantity
                };

                var docStatus = new ThroughPutServices().AddThroughPut(throughPut);
                if (docStatus < 1)
                {
                    gVal.Error = "Process failed. Please try again.";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = docStatus;
                gVal.Error = path;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }

            catch (Exception)
            {
                gVal.Error = "ThroughPut processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }