Ejemplo n.º 1
0
        public string SaveCode(TypeVoucher type = TypeVoucher.XBANLE)
        {
            var result  = "";
            var strType = type.ToString();
            var idRepo  = UnitOfWork.Repository <MdIdBuilder>();
            var config  = idRepo.DbSet.Where(x => x.Type == strType).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = strType,
                    Code    = strType,
                    Current = "0",
                };
                config.Current = config.GenerateNumber();
                idRepo.Insert(config);
            }
            else
            {
                config.Current     = config.GenerateNumber();
                config.ObjectState = ObjectState.Modified;
            }
            result = string.Format("{0}{1}", config.Code, config.Current);
            return(result);
        }
Ejemplo n.º 2
0
        public string BuildCode(TypeVoucher type = TypeVoucher.XBANLE)
        {
            var result  = "";
            var idRepo  = UnitOfWork.Repository <MdIdBuilder>();
            var strType = type.ToString();
            var config  = idRepo.DbSet.Where(x => x.Type == strType).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = type.ToString(),
                    Code    = type.ToString(),
                    Current = "0",
                };
            }
            var maChungTuGenerate = config.GenerateNumber();

            config.Current = maChungTuGenerate;
            result         = string.Format("{0}{1}", config.Code, maChungTuGenerate);
            return(result);
        }