コード例 #1
0
        public async override Task <IWebApiObjectModel> IndexAsync(System.Web.HttpContext context, CancellationToken cancellationToken)
        {
            IWebApiObjectModel model = new WebApiObjectModel();

            model = await PopulateInitialValuesAsync(model, cancellationToken);

            return(model);
        }
コード例 #2
0
        public async Task <IWebApiObjectModel> IndexAsync(System.Web.HttpContext context, long objectId, CancellationToken cancellationToken)
        {
            IWebApiObjectModel model = new WebApiObjectModel();

            model = await _dal.SelectByIDAsync(objectId, userId, cancellationToken);
            await PopulateInitialValuesAsync(model, cancellationToken);

            return(model);
        }
コード例 #3
0
        public async Task <ActionResult> Index(WebApiObjectModel model, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                ViewData[Constant.CustomSuccessMessage] = Constant.CustomValidationErrorMessage;
                ViewData[Constant.QuerySuccess]         = false;
                model = (WebApiObjectModel)await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

                return(View(model));
            }
            ModelState.Clear();
            model = (WebApiObjectModel)await _service.SaveAsync(HttpContext.ApplicationInstance.Context, model, GetCanellationToken(cancellationToken));

            ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
            ViewData[Constant.FormTitle]    = HttpContext.Items[Constant.FormTitle];
            if (System.Convert.ToBoolean(ViewData[Constant.QuerySuccess]))
            {
                ViewData[Constant.FormTitle] = "EDIT Web API Object";
            }
            return(View(model));
        }
コード例 #4
0
        public override async Task <IWebApiObjectModel> SelectByIDAsync(long id, long userId, CancellationToken cancellationToken)
        {
            DataTable dt;

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add(DBObjects.SPParameter.WAObjectId, GetParameter(DBObjects.SPParameter.WAObjectId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, id));
            param.Add(DBObjects.SPParameter.UserId, GetParameter(DBObjects.SPParameter.UserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, userId));
            dt = await this.GetSPDataTableAsync(DBObjects.StoredProcedures.webApi_pspObjectSelectById.ToString(), cancellationToken, param);

            IWebApiObjectModel model = new WebApiObjectModel();

            model.WAObjectId  = Convert.ToInt64(dt.Rows[0][DBObjects.Fields.WAObjectId]);
            model.ModuleId    = Convert.ToInt64(dt.Rows[0][DBObjects.Fields.ModuleId]);
            model.Name        = dt.Rows[0][DBObjects.Fields.Name].ToString();
            model.Description = PublicFunctions.ConvertNULL(dt.Rows[0][DBObjects.Fields.Description], "");
            model.URL         = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0][DBObjects.Fields.URL]));
            model.AllowGet    = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowGet]);
            model.AllowPost   = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowPost]);
            model.AllowPut    = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowPut]);
            model.AllowDelete = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowDelete]);
            model.IsActive    = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.IsActive]);
            return(model);
        }