コード例 #1
0
        public void InitializeFromEnumAndSave()
        {
            var listOfEnums = EnumExtention <ProductCategory1ENUM> .ToList();

            if (listOfEnums.IsNullOrEmpty())
            {
                return;
            }

            listOfEnums.Remove(ProductCategory1ENUM.Unknown.ToString());
            CreateEntitiesFromListOfStrings(listOfEnums as IList <string>);
            Save();

            ProductCategoryMainDAL pCatMainDal = new ProductCategoryMainDAL(_db, _user);

            //remember to create the MainProduct also for these categories
            foreach (var item in listOfEnums)
            {
                try
                {
                    ProductCategoryMain c = pCatMainDal.Factory();
                    c.ProductCat1 = (ICategory)FindForName(item);
                    pCatMainDal.Create(c);
                    pCatMainDal.Save();
                }
                catch (ErrorHandlerLibrary.ExceptionsNS.NoDuplicateException)
                {
                    continue;
                }
            }

            Save();
        }
コード例 #2
0
        public async Task HouseBuild([Remainder] string build_name = null)
        {
            Player player = Context.Player;
            House  house  = await LoadHouse(player, Context.Channel);

            Sandbox sb = house.sandbox;

            if (sb.tiles.Count >= sb.tier)
            {
                await ReplyAsync($"A tier {sb.tier} House may not have more than {sb.tier} buildings");
            }
            else if (EnumExtention.IsEnum(build_name?.Replace(' ', '_'), out SandboxTile.TileType result))
            {
                TileSchematic ts = TileSchematics.GetSchem(result, 0);
                await player.NewUI($"Are you sure you wish to build a {ts}?",
                                   ts.ToEmbed(player.userSettings.Color), Context.Channel, MsgType.ComfirmTile, $"house;0;{(int)result}");
            }
            else
            {
                await ReplyAsync($"{build_name} is not a valid build name. Please write a valid name:"
                                 + Environment.NewLine + EnumExtention.GetNames <SandboxTile.TileType>()
                                 .Join(Environment.NewLine, n => n.Replace('_', ' '))
                                 );
            }
        }
コード例 #3
0
ファイル: PaymentTypeDAL.cs プロジェクト: dovanduy/Library
        public void InitializeFromEnumAndSave()
        {
            var eList = EnumExtention <PaymentTypeENUM> .ToList();

            if (eList.IsNullOrEmpty())
            {
                return;
            }

            //fix the names


            foreach (var item in eList)
            {
                PaymentType c = Factory();
                c.Name = item.ToSentence();
                c.MetaData.IsAutoCreated = true;

                try
                {
                    Create(c);
                }
                catch (ErrorHandlerLibrary.ExceptionsNS.NoDuplicateException)
                {
                }
            }

            Save();
        }
コード例 #4
0
        public async Task <Response <Project> > DeleteAsync(long key)
        {
            if (!_repo.FindAsync(key)
                .Result.Status.Equals(EnumExtention
                                      .GetDescriptionFromEnumValue(EProjectStatus.InProgress)))
            {
                try
                {
                    using (var dbContext = new DbContextFactory().CreateDbContext(new string[] { }))
                    {
                        var success = _repo.Remove(key);
                        await dbContext.SaveChangesAsync();

                        return(new Response <Project>(success));
                    }
                }
                catch (Exception ex)
                {
                    return(new Response <Project>($"An error occurred when saving the delete: {ex.Message}"));
                }
            }
            else
            {
                return(new Response <Project>($"You can't delete an active project! Project not deleted. "));
            }
        }
コード例 #5
0
 protected readonly ISystems _sys; /**/
 public ExternalResponesViewModel(SysCode sysCode, ISystems sys, T data)
 {
     _sys    = sys;
     Code    = (int)sysCode;
     Message = EnumExtention.GetDescription(sysCode);
     if (data != null)
     {
         this.Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data));
     }
 }
コード例 #6
0
 protected readonly ISystems _sys; /**/
 public UnknownViewModel(SysCode sysCode, ISystems sys, T data)
 {
     _sys    = sys;
     Code    = (int)sysCode;
     Message = EnumExtention.GetDescription(sysCode);
     if (data != null)
     {
         this.Data = data;
     }
 }
コード例 #7
0
        public Conversao RealizarCambio(string nome, decimal valor, string entrada, string saida)
        {
            ConversaoAplicacao conversaoAplicacao = new ConversaoAplicacao();
            var cambio    = conversaoAplicacao.Cambio(EnumExtention.GetValueFromDescription <Moedas>(entrada), EnumExtention.GetValueFromDescription <Moedas>(saida), valor);
            var taxa      = 0.10;
            var conversao = new Conversao(nome, Porcentagem(valor, taxa), ValorFinal(valor, taxa), DateTime.Now, entrada, saida, cambio, valor);

            ConvercaoRepositorio.Add(conversao);
            return(conversao);
        }
コード例 #8
0
        public void InitializeFromEnumAndSave()
        {
            //this will create customer categories for the Enums
            //var listOfEnums = Enum.GetNames(typeof(DebitCreditENUM)).ToList();

            var listOfEnums = EnumExtention <DebitCreditENUM> .ToList();

            listOfEnums.Remove(DebitCreditENUM.Unknown.ToString());
            CreateEntitiesFromListOfStrings(listOfEnums);
            Save();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Hengle/GameplayFramework
        static void Main(string[] args)
        {
            Test22 t = Test22.B;

            EnumExtention.Add(ref t, Test22.C);

            bool res = t.Contain(Test22.C);

            EnumExtention.Remove(ref t, Test22.C);

            Console.ReadLine();
        }
コード例 #10
0
        public MapProfile()
        {
            CreateMap <ProjectDTO, Project>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetDescriptionFromEnumValue(s.Status)));
            CreateMap <Project, ProjectDTO>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetEnumValueFromDescription <EProjectStatus>(s.Status)));

            CreateMap <SaveProjectDTO, Project>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetDescriptionFromEnumValue(s.Status)));
            CreateMap <Project, SaveProjectDTO>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetEnumValueFromDescription <EProjectStatus>(s.Status)));
        }
コード例 #11
0
ファイル: MapProfile.cs プロジェクト: OlehKuz/HomeWorkProject
        public MapProfile()
        {
            CreateMap <ProjectPutDto, Project>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetDescriptionFromEnumValue(s.Status)));
            CreateMap <Project, ProjectPutDto>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetEnumValueFromDescription <EProjectStatus>(s.Status)));

            CreateMap <ProjectPostDto, Project>()
            .ForMember(dest => dest.Status,
                       src => src.MapFrom(s => EnumExtention.GetDescriptionFromEnumValue(s.Status)));
            CreateMap <Project, ProjectGetDto>();

            CreateMap <Employee, EmployeeDTO>();
            CreateMap <EmployeeDTO, Employee>();
        }
コード例 #12
0
        public GameResponesViewModel(SysCode sysCode, T data, ISystems sys, string appkey, string requestId, string nonce)
        {
            _sys = sys;
            string appSecret = _sys.GetAppConfig(appkey).Secret;

            code      = (int)sysCode;
            message   = EnumExtention.GetDescription(sysCode);
            timestamp = TimeHelper.ConvertDateTimeToInt(DateTime.Now.ToLocalTime()).ToString();
            if (data != null)
            {
                this.data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data));
                sign      = _sys.Sha512Encode($"{appkey}{appSecret}{this.data}{nonce}{timestamp}");
            }
            else
            {
                sign = _sys.Sha512Encode($"{appkey}{appSecret}{nonce}{timestamp}");
            }
            this.requestId = requestId;
            this.appKey    = appkey;
            this.nonce     = nonce;
            page           = null; //用不上
            signType       = "sha_512";
        }
コード例 #13
0
 protected readonly ISystems _sys; /**/
 /// <summary>
 /// 返回值构造函数
 /// author:陶林辉
 /// </summary>
 /// <param name="sysCode">错误枚举</param>
 /// <param name="data">返回业务参数</param>
 /// <param name="encrypt">加密方式</param>
 public ResponseViewModel(SysCode sysCode, T data, string encrypt, ISystems sys, string secret)
 {
     _sys      = sys;
     Code      = (int)sysCode;
     Message   = EnumExtention.GetDescription(sysCode);
     Datetime  = DateTime.Now.ToLocalTime().ToString();
     Timestamp = TimeHelper.ConvertDateTimeToInt(DateTime.Now.ToLocalTime());
     if (encrypt == "0")
     {
         if (data != null)
         {
             this.Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data));
         }
     }
     else if (encrypt == "1")
     {
         if (data != null)
         {
             this.Data = _sys.AesEncrypt(secret, JsonHelper.SerializeObject(data));
         }
     }
     this.Encrypt = encrypt;
 }
コード例 #14
0
ファイル: SelectList.cs プロジェクト: dovanduy/Library
 public SelectList SelectListSex()
 {
     return(EnumExtention.ToSelectListSorted <SexENUM>(SexENUM.Unknown));
 }
コード例 #15
0
ファイル: SelectList.cs プロジェクト: dovanduy/Library
        //public SelectList SelectListUser
        //{
        //    get { return UserBiz.SelectList(); }
        //}



        //public SelectList SelectListBillAddressesFor(string userId)
        //{
        //    //return AddressBiz.SelectListBillAddressFor(userId);
        //}


        //public SelectList SelectListShipAddressesFor(string userId)
        //{
        //    return AddressBiz.SelectListShipAddressFor(userId);
        //}

        public SelectList SelectListSonOfWifeOf()
        {
            return(EnumExtention.ToSelectListSorted <SonOfWifeOfDotOfENUM>(SonOfWifeOfDotOfENUM.Unknown));
        }
コード例 #16
0
 public H5ResponseViewModel(SysCode sysCode, T data)
 {
     Code      = (int)sysCode;
     Message   = EnumExtention.GetDescription(sysCode);
     this.data = data;
 }