Exemplo n.º 1
0
 public ResponseCrud(HttpStatusCode statusCode, CrudEnum crudJob, bool hasError = false, string errorMessage = null, T t = null)
 {
     Status       = statusCode;
     CrudJob      = crudJob;
     HasError     = hasError;
     ErrorMessage = errorMessage;
     Entity       = t;
 }
Exemplo n.º 2
0
 /// <summary>
 /// check program access right
 /// </summary>
 /// <param name="authStrs">program auth string list, has ',' at begin/end</param>
 /// <param name="prog">program id</param>
 /// <param name="crudEnum">crud function, see CrudFunEstr, empty for controller, value for action</param>
 /// <returns>bool</returns>
 public static bool CheckAuth(string authStrs, string prog, CrudEnum crudEnum)
 {
     if (_Fun.AuthType == AuthTypeEnum.Ctrl)
     {
         //authStr format: ,xxx,xxx,
         return(authStrs.Contains("," + prog + ",", StringComparison.CurrentCulture));
     }
     else
     {
         //authStr format: ,xxx:121,xxx:001,
         return((crudEnum == CrudEnum.Empty)
             ? authStrs.Contains("," + prog + ":")
             : GetAuthRange(authStrs, prog, crudEnum) != AuthRangeEnum.None);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// get auth range of crud fun
        /// </summary>
        /// <param name="prog"></param>
        /// <param name="crudEnum"></param>
        /// <param name="authStrs"></param>
        /// <returns></returns>
        public static AuthRangeEnum GetAuthRange(string authStrs, string prog, CrudEnum crudEnum)
        {
            //if (authStrs == null)
            //    authStrs = _Fun.GetBaseUser().ProgAuthStrs;
            //var sep = ",";
            var funList = _Str.GetMid(authStrs, "," + prog + ":", ",");
            var funPos  = (int)crudEnum;

            if (funList.Length <= funPos)
            {
                return(AuthRangeEnum.None);
            }

            //pos 0, fun is auth row or not(0/1)
            var auth = (AuthRangeEnum)Convert.ToInt32(funList.Substring(funPos, 1));

            return((funList[..1] == "1") ? auth :
Exemplo n.º 4
0
        public virtual ValidationError Validate(CrudEnum crudType, bool allowCreateSpecifyId)
        {
            var result = new ValidationError();

            if (crudType != CrudEnum.Create && !Timestamp.HasValue)
            {
                result.InvalidInputs.Add("Timestamp", "Timestamp already set.");
            }

            if (crudType == CrudEnum.Create && !allowCreateSpecifyId && !string.IsNullOrEmpty(this.Id))
            {
                result.InvalidInputs.Add("Id", "Id must be null.");
            }

            if (crudType != CrudEnum.Create && string.IsNullOrEmpty(this.Id))
            {
                result.InvalidInputs.Add("Id", "Id must be specified.");
            }

            return(result);
        }
Exemplo n.º 5
0
 public DBProperty GetProperty(CrudEnum crudEnum)
 => sqlDictonnary[crudEnum];
Exemplo n.º 6
0
 public XgProgAuthAttribute(CrudEnum crudEnum = CrudEnum.Empty)
 {
     _crudEnum = crudEnum;
 }
Exemplo n.º 7
0
 CrudKeuze(CrudEnum index, string description)
 {
     this.Index       = index;
     this.Description = description;
 }