Пример #1
0
        public ActionResult Add([ModelBinder(typeof(JsonBinder <StorageEntity>))] StorageEntity entity)
        {
            StorageProvider provider = new StorageProvider();
            int             line     = 0;

            if (entity.StorageNum.IsEmpty())
            {
                entity.CreateTime = DateTime.Now;
                entity.StorageNum = entity.StorageNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(StorageEntity)) : entity.StorageNum;
                entity.IsDelete   = (int)EIsDelete.NotDelete;
                entity.IsForbid   = (int)EBool.No;
                line = provider.Add(entity);
            }
            else
            {
                entity.Include(a => new { a.StorageName, a.StorageType, a.Length, a.Width, a.Height, a.Action, a.Status, a.IsDefault, a.Remark });
                entity.Where(a => a.StorageNum == entity.StorageNum);
                line = provider.Update(entity);
            }
            if (line > 0)
            {
                this.ReturnJson.AddProperty("d", "success");
            }
            else
            {
                this.ReturnJson.AddProperty("d", "");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Пример #2
0
        /// <summary>
        ///     Creates a new <see cref="IBuildInfoModel" /> for update a captcha.
        /// </summary>
        /// <param name="parameterContainer">
        ///     The specified <see cref="IParameterContainer" />.
        /// </param>
        /// <returns>
        ///     An instance of <see cref="IUpdateInfoModel" />.
        /// </returns>
        public IUpdateInfoModel Update(IParameterContainer parameterContainer)
        {
            Validate.ArgumentNotNull(parameterContainer, "parameterContainer");
            string token;

            parameterContainer.TryGet(TokenParameterName, out token, null);
            if (string.IsNullOrEmpty(token))
            {
                throw new KeyNotFoundException("The key is to generate not found.");
            }
            ICaptchaValue captchaValue = StorageProvider.GetValue(token, TokenType.Validation);

            if (captchaValue == null)
            {
                throw new ArgumentException("The key is to update incorrect.");
            }

            HttpRequestBase request;

            if (!parameterContainer.TryGet(RequestParameterContainer.HttpRequestParameterKey, out request) ||
                request == null)
            {
                throw new InvalidOperationException(
                          "The parameterContainer does not contain a HttpRequestBase with key RequestParameterContainer.HttpRequestParameterKey.");
            }
            KeyValuePair <string, ICaptchaValue> captchaPair = CreateCaptchaPair(parameterContainer, captchaValue);
            string newUrl = ImageUrlFactory(new UrlHelper(request.RequestContext), captchaPair);

            StorageProvider.Add(captchaPair);
            return(new DefaultUpdateInfoModel(TokenElementName, captchaPair.Key, newUrl, ImageElementName));
        }
Пример #3
0
        /// <summary>
        /// 新增仓库
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string   StorageNum  = WebUtil.GetFormValue <string>("StorageNum");
            string   StorageName = WebUtil.GetFormValue <string>("StorageName");
            int      StorageType = WebUtil.GetFormValue <int>("StorageType");
            double   Length      = WebUtil.GetFormValue <double>("Length");
            double   Width       = WebUtil.GetFormValue <double>("Width");
            double   Height      = WebUtil.GetFormValue <double>("Height");
            string   Action      = WebUtil.GetFormValue <string>("Action");
            string   Remark      = WebUtil.GetFormValue <string>("Remark");
            string   Contact     = WebUtil.GetFormValue <string>("Contact");
            string   Phone       = WebUtil.GetFormValue <string>("Phone");
            string   Address     = WebUtil.GetFormValue <string>("Address");
            double   Area        = WebUtil.GetFormValue <double>("Area");
            string   DepartNum   = WebUtil.GetFormValue <string>("DepartNum");
            string   CreateUser  = WebUtil.GetFormValue <string>("CreateUser");
            string   CompanyID   = WebUtil.GetFormValue <string>("CompanyID");
            DateTime LeaseTime   = WebUtil.GetFormValue <DateTime>("LeaseTime", DateTime.Now.AddYears(1));

            StorageEntity entity = new StorageEntity();

            entity.StorageName = StorageName;
            entity.StorageType = StorageType;
            entity.Length      = Length;
            entity.Width       = Width;
            entity.Height      = Height;
            entity.Action      = Action;
            entity.IsDelete    = (int)EIsDelete.NotDelete;
            entity.CreateTime  = DateTime.Now;
            entity.Remark      = Remark;
            entity.Contact     = Contact;
            entity.Phone       = Phone;
            entity.Address     = Address;
            entity.Area        = Area;
            entity.DepartNum   = DepartNum;
            entity.LeaseTime   = LeaseTime;
            entity.CreateUser  = CreateUser;
            entity.CompanyID   = CompanyID;

            StorageProvider provider = new StorageProvider(CompanyID);
            int             line     = provider.Add(entity);
            DataResult      result   = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "仓库新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "仓库新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Пример #4
0
        /// <summary>
        ///     Creates a <see cref="IUpdateInfoModel" /> for create a new captcha.
        /// </summary>
        /// <param name="controller">
        ///     The specified <see cref="ControllerBase" />.
        /// </param>
        /// <param name="parameterContainer">
        ///     The specified <see cref="IParameterContainer" />.
        /// </param>
        /// <returns>
        ///     An instance of <see cref="IUpdateInfoModel" />.
        /// </returns>
        public virtual IUpdateInfoModel GenerateNew(ControllerBase controller, IParameterContainer parameterContainer)
        {
            Validate.ArgumentNotNull(controller, "controller");
            Validate.ArgumentNotNull(parameterContainer, "parameterContainer");
            KeyValuePair <string, ICaptchaValue> captchaPair = CreateCaptchaPair(parameterContainer, null);

            StorageProvider.Add(captchaPair);
            var    urlHelper = new UrlHelper(controller.ControllerContext.RequestContext);
            string imgUrl    = ImageUrlFactory(urlHelper, captchaPair);

            return(new DefaultUpdateInfoModel(TokenElementName, captchaPair.Key, imgUrl, ImageElementName));
        }
Пример #5
0
        /// <summary>
        ///     Creates a <see cref="IBuildInfoModel" /> for create a new captcha.
        /// </summary>
        /// <param name="htmlHelper">
        ///     The specified <see cref="HtmlHelper" />.
        /// </param>
        /// <param name="parameterContainer">
        ///     The specified <see cref="IParameterContainer" />.
        /// </param>
        /// <returns>
        ///     An instance of <see cref="IBuildInfoModel" />.
        /// </returns>
        public virtual IBuildInfoModel GenerateNew(HtmlHelper htmlHelper, IParameterContainer parameterContainer)
        {
            Validate.ArgumentNotNull(htmlHelper, "htmlHelper");
            Validate.ArgumentNotNull(parameterContainer, "parameterContainer");
            KeyValuePair <string, ICaptchaValue> captchaPair = CreateCaptchaPair(parameterContainer, null);

            StorageProvider.Add(captchaPair);
            var    urlHelper  = new UrlHelper(htmlHelper.ViewContext.RequestContext);
            string imgUrl     = ImageUrlFactory(urlHelper, captchaPair);
            string refreshUrl = RefreshUrlFactory(urlHelper, captchaPair);

            return(CreateBuildInfo(htmlHelper, parameterContainer, captchaPair, imgUrl, refreshUrl));
        }