Example #1
0
 public WikiModel(
     Context context,
     SiteSettings ss,
     long wikiId,
     bool clearSessions     = false,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context = context;
     WikiId  = wikiId;
     SiteId  = ss.SiteId;
     Get(context: context, ss: ss);
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     if (setByForm)
     {
         SetByForm(context: context, ss: ss);
     }
     if (setByApi)
     {
         SetByApi(context: context, ss: ss);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #2
0
 public GroupModel(
     SiteSettings ss,
     int groupId,
     bool clearSessions       = false,
     bool setByForm           = false,
     bool setByApi            = false,
     List <int> switchTargets = null,
     MethodTypes methodType   = MethodTypes.NotSet)
 {
     OnConstructing();
     GroupId = groupId;
     Get(ss);
     if (clearSessions)
     {
         ClearSessions();
     }
     if (setByForm)
     {
         SetByForm(ss);
     }
     if (setByApi)
     {
         SetByApi(ss);
     }
     SwitchTargets = switchTargets;
     MethodType    = methodType;
     OnConstructed();
 }
 public ExtensionModel(
     Context context,
     int extensionId,
     bool clearSessions     = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context     = context;
     ExtensionId = extensionId;
     if (context.QueryStrings.ContainsKey("ver"))
     {
         Get(context: context,
             tableType: Sqls.TableTypes.NormalAndHistory,
             where : Rds.ExtensionsWhereDefault(
                 context: context,
                 extensionModel: this)
             .Extensions_Ver(context.QueryStrings.Int("ver")));
     }
     else
     {
         Get(context: context);
     }
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #4
0
 public DeptModel(
     Context context,
     SiteSettings ss,
     int deptId,
     bool clearSessions       = false,
     bool setByForm           = false,
     bool setByApi            = false,
     List <int> switchTargets = null,
     MethodTypes methodType   = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     TenantId = context.TenantId;
     DeptId   = deptId;
     Get(context: context, ss: ss);
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     if (setByForm)
     {
         SetByForm(context: context, ss: ss);
     }
     if (setByApi)
     {
         SetByApi(context: context, ss: ss);
     }
     SwitchTargets = switchTargets;
     MethodType    = methodType;
     OnConstructed(context: context);
 }
Example #5
0
 public DemoModel(
     Context context,
     int demoId,
     bool clearSessions     = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     TenantId = context.TenantId;
     DemoId   = demoId;
     if (context.QueryStrings.ContainsKey("ver"))
     {
         Get(context: context,
             tableType: Sqls.TableTypes.NormalAndHistory,
             where : Rds.DemosWhereDefault(this)
             .Demos_Ver(context.QueryStrings.Int("ver")));
     }
     else
     {
         Get(context: context);
     }
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
 public WikiModel(
     SiteSettings ss,
     long wikiId,
     bool clearSessions     = false,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     WikiId = wikiId;
     SiteId = ss.SiteId;
     Get(ss);
     if (clearSessions)
     {
         ClearSessions();
     }
     if (setByForm)
     {
         SetByForm(ss);
     }
     if (setByApi)
     {
         SetByApi(ss);
     }
     MethodType = methodType;
     OnConstructed();
 }
Example #7
0
 public MailAddressModel(
     Context context,
     long mailAddressId,
     bool clearSessions     = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context       = context;
     MailAddressId = mailAddressId;
     if (context.QueryStrings.ContainsKey("ver"))
     {
         Get(context: context,
             tableType: Sqls.TableTypes.NormalAndHistory,
             where : Rds.MailAddressesWhereDefault(this)
             .MailAddresses_Ver(context.QueryStrings.Int("ver")));
     }
     else
     {
         Get(context: context);
     }
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
 public OutgoingMailModel(
     Context context,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     MethodType = methodType;
     OnConstructed(context: context);
 }
 public ExportSettingModel(
     Context context,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #10
0
 public MailAddressModel(
     Context context,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #11
0
 public DemoModel(
     Context context,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     TenantId   = context.TenantId;
     MethodType = methodType;
     OnConstructed(context: context);
 }
 public OutgoingMailModel(
     bool setByForm = false,
     bool setByApi = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     if (setByForm) SetByForm();
     MethodType = methodType;
     OnConstructed();
 }
Example #13
0
        /// <summary>
        /// Retrieve the method parameter for a given constant ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool HasParameter(MethodTypes id, string parameterName)
        {
            var method = MethodParameters.FirstOrDefault(c => c.Method == id);

            if (method != null && method.Parameters.ContainsKey(parameterName))
            {
                return(true);
            }

            return(false);
        }
Example #14
0
 public HealthModel(
     Context context,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #15
0
 public BinaryModel(
     Context context,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context    = context;
     TenantId   = context.TenantId;
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #16
0
 public TenantModel(
     bool setByForm         = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     if (setByForm)
     {
         SetByForm();
     }
     MethodType = methodType;
     OnConstructed();
 }
 public UserModel(
     SiteSettings ss,
     bool setByForm         = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     if (setByForm)
     {
         SetByForm(ss);
     }
     MethodType = methodType;
     OnConstructed();
 }
 public ExportSettingModel(
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     if (setByForm)
     {
         SetByForm();
     }
     MethodType = methodType;
     OnConstructed();
 }
Example #19
0
        private static bool IsCorrectDelegateType(MethodTypes methodTypes, IMethodSymbol delegateMethod, SyntaxNodeAnalysisContext context, out string delegateText)
        {
            if (!methodTypes.ReturnType.Equals(delegateMethod.ReturnType))
            {
                delegateText = DelegateText();
                return(false);
            }

            if (methodTypes.Count == delegateMethod.Parameters.Length)
            {
                for (var i = 0; i < delegateMethod.Parameters.Length; i++)
                {
                    if (!methodTypes[i].Equals(delegateMethod.Parameters[i].Type))
                    {
                        delegateText = DelegateText();
                        return(false);
                    }
                }

                delegateText = null;
                return(true);
            }

            delegateText = DelegateText();
            return(false);

            string DelegateText()
            {
                if (methodTypes.ReturnType.SpecialType == SpecialType.System_Void)
                {
                    if (methodTypes.Count == 0)
                    {
                        return("System.Action");
                    }

                    return(StringBuilderPool.Borrow()
                           .Append("System.Action<")
                           .Append(methodTypes.TypeArgsText(context))
                           .Append(">")
                           .Return());
                }

                return(StringBuilderPool.Borrow()
                       .Append("System.Func<")
                       .Append(methodTypes.TypeArgsText(context))
                       .Append(">")
                       .Return());
            }
        }
 public OutgoingMailModel(
     long outgoingMailId,
     bool clearSessions = false,
     bool setByForm = false,
     bool setByApi = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing();
     OutgoingMailId = outgoingMailId;
     Get();
     if (clearSessions) ClearSessions();
     if (setByForm) SetByForm();
     MethodType = methodType;
     OnConstructed();
 }
Example #21
0
 public DeptModel(
     Context context,
     SiteSettings ss,
     int deptId,
     Dictionary <string, string> formData = null,
     bool setByApi            = false,
     bool clearSessions       = false,
     List <int> switchTargets = null,
     MethodTypes methodType   = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     TenantId = context.TenantId;
     DeptId   = deptId;
     if (context.QueryStrings.ContainsKey("ver"))
     {
         Get(context: context,
             tableType: Sqls.TableTypes.NormalAndHistory,
             where : Rds.DeptsWhereDefault(
                 context: context,
                 deptModel: this)
             .Depts_Ver(context.QueryStrings.Int("ver")), ss: ss);
     }
     else
     {
         Get(context: context, ss: ss);
     }
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     if (formData != null)
     {
         SetByForm(
             context: context,
             ss: ss,
             formData: formData);
     }
     if (setByApi)
     {
         SetByApi(context: context, ss: ss);
     }
     SwitchTargets = switchTargets;
     MethodType    = methodType;
     OnConstructed(context: context);
 }
        /// <summary>
        /// Фабричный метод для получения метода
        /// </summary>
        /// <param name="methodType">Метод</param>
        /// <param name="func">Правая часть</param>
        /// <returns></returns>
        private MethodBase GetMethod(MethodTypes methodType, Func <double, double, double> func)
        {
            switch (methodType)
            {
            case MethodTypes.Explicit:
                return(new ExplicitMethod(func));

            case MethodTypes.Implicit:
                return(new ImplicitMethod(func));

            case MethodTypes.CrankNicolson:
                return(new CrankNicolsonMethod(func));

            default:
                throw new NotSupportedException($"Метод {methodType} не поддерживается");
            }
        }
Example #23
0
 public TenantModel(
     Context context,
     bool clearSessions     = false,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     TenantId = context.TenantId;
     Get(context: context);
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #24
0
        public bool IsValid(MethodTypes httpMethod, CashRegisterDto cashRegisterDto, out string message)
        {
            message = "";
            switch (httpMethod)
            {
            case MethodTypes.Post:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    if (dbContext.CashRegisters.Any(u => u.IsActive &&
                                                    u.Name.Equals(cashRegisterDto.Name,
                                                                  StringComparison.CurrentCultureIgnoreCase) && u.StoreId == cashRegisterDto.Store.Id))
                    {
                        message = $"Ya existe una caja llamada {cashRegisterDto.Name}.";
                        return(false);
                    }
                }
                break;
            }

            case MethodTypes.Put:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    var cashRegister = dbContext.CashRegisters.Find(cashRegisterDto.Id);
                    if (cashRegister == null)
                    {
                        message = "Caja no encontrada.";
                        return(false);
                    }

                    if (dbContext.CashRegisters.Any(u => u.IsActive && u.Id != cashRegisterDto.Id &&
                                                    u.Name.Equals(cashRegisterDto.Name,
                                                                  StringComparison.CurrentCultureIgnoreCase) && u.StoreId == cashRegisterDto.Store.Id))
                    {
                        message = $"Ya existe una caja llamada {cashRegisterDto.Name}.";
                        return(false);
                    }
                }
                break;
            }
            }
            return(true);
        }
Example #25
0
        public bool IsValid(MethodTypes httpMethod, BrandDto brandDto, out string message)
        {
            message = "";
            switch (httpMethod)
            {
            case MethodTypes.Post:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    if (dbContext.Brands.Any(u => u.IsActive &&
                                             u.Name.Equals(brandDto.Name,
                                                           StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe una marca llamada {brandDto.Name}.";
                        return(false);
                    }
                }
                break;
            }

            case MethodTypes.Put:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    var brand = dbContext.Brands.Find(brandDto.Id);
                    if (brand == null)
                    {
                        message = "Marca no encontrada.";
                        return(false);
                    }

                    if (dbContext.Brands.Any(u => u.IsActive && u.Id != brandDto.Id &&
                                             u.Name.Equals(brandDto.Name,
                                                           StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe una marca llamada {brandDto.Name}.";
                        return(false);
                    }
                }
                break;
            }
            }
            return(true);
        }
Example #26
0
        public bool IsValid(MethodTypes httpMethod, CustomerDto customerDto, out string message)
        {
            message = "";
            switch (httpMethod)
            {
            case MethodTypes.Post:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    if (dbContext.Customers.Any(u => u.IsActive &&
                                                u.Name.Equals(customerDto.Name,
                                                              StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe un cliente con el nombre {customerDto.Name}.";
                        return(false);
                    }
                }
                break;
            }

            case MethodTypes.Put:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    var customer = dbContext.Customers.Find(customerDto.Id);
                    if (customer == null)
                    {
                        message = "Cliente no encontrado.";
                        return(false);
                    }

                    if (dbContext.Customers.Any(u => u.IsActive && u.Id != customerDto.Id &&
                                                u.Name.Equals(customerDto.Name,
                                                              StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe un cliente con el nombre {customerDto.Name}.";
                        return(false);
                    }
                }
                break;
            }
            }
            return(true);
        }
Example #27
0
        public bool IsValid(MethodTypes httpMethod, VendorDto vendorDto, out string message)
        {
            message = "";
            switch (httpMethod)
            {
            case MethodTypes.Post:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    if (dbContext.Vendors.Any(u => u.IsActive &&
                                              u.Name.Equals(vendorDto.Name,
                                                            StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe un provedeor con el nombre {vendorDto.Name}.";
                        return(false);
                    }
                }
                break;
            }

            case MethodTypes.Put:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    var vendor = dbContext.Vendors.Find(vendorDto.Id);
                    if (vendor == null)
                    {
                        message = "Proveedor no encontrado.";
                        return(false);
                    }

                    if (dbContext.Vendors.Any(u => u.IsActive && u.Id != vendorDto.Id &&
                                              u.Name.Equals(vendorDto.Name,
                                                            StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe un proveedor con el nombre {vendorDto.Name}.";
                        return(false);
                    }
                }
                break;
            }
            }
            return(true);
        }
Example #28
0
        public bool IsValid(MethodTypes httpMethod, StoreDto storeDto, out string message)
        {
            message = "";
            switch (httpMethod)
            {
            case MethodTypes.Post:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    if (dbContext.Stores.Any(u => u.IsActive &&
                                             u.Name.Equals(storeDto.Name,
                                                           StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe una sucursal llamada {storeDto.Name}.";
                        return(false);
                    }
                }
                break;
            }

            case MethodTypes.Put:
            {
                using (PosRiContext dbContext = new PosRiContext())
                {
                    var store = dbContext.Stores.Find(storeDto.Id);
                    if (store == null)
                    {
                        message = "Sucursal no encontrada.";
                        return(false);
                    }

                    if (dbContext.Stores.Any(u => u.IsActive && u.Id != storeDto.Id &&
                                             u.Name.Equals(storeDto.Name,
                                                           StringComparison.CurrentCultureIgnoreCase)))
                    {
                        message = $"Ya existe una sucursal llamada {storeDto.Name}.";
                        return(false);
                    }
                }
                break;
            }
            }
            return(true);
        }
Example #29
0
 public HealthModel(
     Context context,
     long healthId,
     bool clearSessions     = false,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     HealthId = healthId;
     Get(context: context);
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
Example #30
0
 public OutgoingMailModel(
     Context context,
     long outgoingMailId,
     bool clearSessions     = false,
     bool setByForm         = false,
     bool setByApi          = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context        = context;
     OutgoingMailId = outgoingMailId;
     Get(context: context);
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }