Beispiel #1
0
        public ActionResult ValidateRefund(string OrderID, string TelePhone, string CodeStr)
        {
            var validateResult = new CodeService().ValidateCodeWithOutTime(TelePhone, CodeStr, Code_Type.Refund);

            if (!(validateResult != null && validateResult.status > 0))
            {
                ViewBag.tipStr = "验证申请授权错误";
            }

            var refundResult = new RefundService().SelectByID(OrderID);

            if (refundResult != null && refundResult.RefundStatus == (int)Order_Status.Refunding)
            {
                var RecordEntity = new RecordService().SelectByID(OrderID);
                ViewBag.OrderID     = RecordEntity != null ? RecordEntity.RecordID : OrderID;
                ViewBag.OrderNo     = RecordEntity != null ? RecordEntity.OrderNo : "";
                ViewBag.Amount      = RecordEntity != null ? RecordEntity.Amount : 0;
                ViewBag.Description = RecordEntity != null ? RecordEntity.Description : "";

                ViewBag.RefundAmount = refundResult.Amount;
                ViewBag.RefundRemark = refundResult.Remark;

                ViewBag.tipStr = "";
            }
            else
            {
                ViewBag.tipStr = "退款单已处理";
            }
            return(View());
        }
Beispiel #2
0
        public async Task TestDeleteBadCode()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            RegistrationCode code1 = new RegistrationCode {
                Code = "code1", Apartment = apartment1
            };
            RegistrationCode code2 = new RegistrationCode {
                Code = "code2", Apartment = apartment2
            };
            await context.RegistrationCodes.AddAsync(code1);

            await context.RegistrationCodes.AddAsync(code2);

            await context.SaveChangesAsync();

            await Assert.ThrowsAsync <ACMException>(() => codeService.DeleteCode("not a real code"));
        }
        public void GetClassDefinition_MultiProperty_Test()
        {
            // arrange
            var expected = "public class Sample { public int Age { get; set; } public string Name { get; set; } public string Phone { get; set; } }";
            var m        = new CodeViewModel {
                Name   = "Sample",
                Fields = new List <FieldViewModel>
                {
                    new FieldViewModel {
                        Type = "int", Name = "Age"
                    },
                    new FieldViewModel {
                        Type = "string", Name = "Name"
                    },
                    new FieldViewModel {
                        Type = "string", Name = "Phone"
                    }
                }
            };
            //var mockService = new Mock<ICodeService<CodeViewModel>>();
            //CodeService service = new CodeService(mockService.Object);
            CodeService service = new CodeService();

            // act
            var actual = service.GetClassDefinition(m);

            // assert
            actual = ReplaceCodeWhitespace(actual);
            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
 public ServicesManager(
     DataManager dataManager
     )
 {
     _dataManager = dataManager;
     _codeService = new CodeService(_dataManager);
 }
        // GET: Orders
        public ActionResult Index(Models.Customer selectitem)
        {
            ViewBag.Customerdata = customerService.GetCustomer(selectitem);

            CodeService           CodeService = new CodeService();
            List <Code>           result1     = CodeService.GetTitle();
            List <SelectListItem> CodeData    = new List <SelectListItem>();

            CodeData.Add(new SelectListItem()
            {
                Text  = "",
                Value = null
            });
            foreach (var item1 in result1)
            {
                CodeData.Add(new SelectListItem()
                {
                    Text  = item1.CodeVal.ToString(),
                    Value = item1.CodeId.ToString()
                });
                ViewData["CodeData"] = CodeData;
            }

            return(View(new Models.Customer()));
        }
Beispiel #6
0
        private static void GenerateStructs()
        {
            //if (DataService.Provider == null)
            SetProvider();

            string lang    = _language;
            string fileExt = FileExtension.DOT_CS;

            if (FileExtension.IsVB(lang))
            {
                language = new VBCodeLanguage();
                fileExt  = FileExtension.DOT_VB;
            }

            string outDir = GetOutputDirectory();

            if (outDir == string.Empty)
            {
                outDir = Directory.GetCurrentDirectory();
            }
            string outPath = Path.Combine(outDir, "AllStructs" + fileExt);

            AddLogEntry(LogState.Information, "Generating Structs to " + outPath);
            TurboTemplate tt = CodeService.BuildStructsTemplate(language, DataService.Provider);

            tt.OutputPath = outPath;
            turboCompiler.AddTemplate(tt);


            AddLogEntry(LogState.Information, "Finished");
        }
Beispiel #7
0
        public async Task TestGetAllCodesGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            RegistrationCode code1 = new RegistrationCode {
                Code = "code1", Apartment = apartment1
            };
            RegistrationCode code2 = new RegistrationCode {
                Code = "code2", Apartment = apartment2
            };
            await context.RegistrationCodes.AddAsync(code1);

            await context.RegistrationCodes.AddAsync(code2);

            await context.SaveChangesAsync();

            var list = codeService.GetAllCodes();

            Assert.Equal(2, list.Count);
            Assert.Equal(1, list[0].ApartmentNumber);
            Assert.Equal("code1", list[0].Code);
            Assert.Equal(2, list[1].ApartmentNumber);
            Assert.Equal("code2", list[1].Code);
        }
Beispiel #8
0
        public async Task TestDeleteCodeGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            RegistrationCode code1 = new RegistrationCode {
                Code = "code1", Apartment = apartment1
            };
            RegistrationCode code2 = new RegistrationCode {
                Code = "code2", Apartment = apartment2
            };
            await context.RegistrationCodes.AddAsync(code1);

            await context.RegistrationCodes.AddAsync(code2);

            await context.SaveChangesAsync();

            bool output = await codeService.DeleteCode(code1.Code);

            Assert.True(output);
            Assert.Single(context.RegistrationCodes.ToList());
            Assert.Equal("code2", context.RegistrationCodes.ToList()[0].Code);
        }
 public Object GetCode(string RoomName, string TypeName, string Problem, string TopClass)
 {
     using (var sqlconnection = new SqlConnection(connectionString))
     {
         CodeService repository = new CodeService(sqlconnection);
         string      strsql     = " where 1=1 ";
         if (RoomName != "" && RoomName != null)
         {
             strsql += " and RoomName='" + RoomName + "' ";
         }
         if (TypeName != "" && TypeName != null)
         {
             strsql += " and TypeName='" + TypeName + "'";
         }
         if (Problem != "" && Problem != null)
         {
             strsql += " and Problem='" + Problem + "'";
         }
         if (TopClass != "" && TopClass != null)
         {
             strsql += " and TopClass='" + TopClass + "'";
         }
         return(repository.GetCodeByWhere(strsql));
     }
 }
Beispiel #10
0
        //private static string GetNamespace(DataProvider provider)
        //{
        //    string nameSpace = GetArg(ConfigurationPropertyName.GENERATED_NAMESPACE) ?? string.Empty;
        //    if (nameSpace.Length == 0)
        //        nameSpace = provider.GeneratedNamespace ?? string.Empty;
        //    if (nameSpace.Length == 0)
        //        nameSpace = provider.Name ?? string.Empty;
        //    if (nameSpace.Length == 0)
        //        throw new InvalidOperationException("Something is seriously FUBAR! We can't get a namespace. The provider name should be set.");
        //    return nameSpace;
        //}

        private static void GenerateViews()
        {
            //if (DataService.Provider == null)
            SetProvider();

            string lang    = _language;
            string fileExt = FileExtension.DOT_CS;

            if (FileExtension.IsVB(lang))
            {
                language = new VBCodeLanguage();
                fileExt  = FileExtension.DOT_VB;
            }

            //loop the providers, and if there's more than one, output to their own folder
            //for tidiness
            foreach (DataProvider provider in DataService.Providers)
            {
                //get the view list
                string[] views  = DataService.GetViewNames(provider.Name);
                string   outDir = GetOutSubDir(provider);

                foreach (string tbl in views)
                {
                    if (IsInList(tbl) && !IsExcluded(tbl) && CodeService.ShouldGenerate(tbl, provider.Name))
                    {
                        string        className = DataService.GetSchema(tbl, provider.Name, TableType.View).ClassName;
                        TurboTemplate tt        = CodeService.BuildViewTemplate(tbl, language, provider);
                        tt.OutputPath = Path.Combine(outDir, className + fileExt);
                        turboCompiler.AddTemplate(tt);
                    }
                }
            }
        }
Beispiel #11
0
        public void CodeService_success()
        {
            //Arrange
            var mockService = new Mock <IDatabase>();
            var service     = new CodeService(mockService.Object);
            var vm          = new CodeRedeemViewModel
            {
                Code          = "",
                UserAccountId = ""
            };

            mockService.Setup(serv => serv.FindGameKey(""))
            .Returns((new GameKey {
                GameId = 1, IsRedeemed = false
            }));

            mockService.Setup(serv => serv.FindOwnership(""))
            .Returns((new List <Ownership>()));

            //Act
            var result = service.RedeemCode(vm: vm);

            //Assert
            Assert.True(result);
        }
Beispiel #12
0
        private void data_Bind()
        {
            //项目数据
            var projectList = XMProjectService.GetXMProjectList();

            Store2.DataSource = projectList;
            Store2.DataBind();

            //发货点数据(发货仓)
            var codeList = CodeService.GetCodeListInfoByCodeTypeID(227);

            Store3.DataSource = codeList;
            Store3.DataBind();

            //省份数据
            var provinceList = AreaCodeService.GetAreaCodeByRank(2);

            Store4.DataSource = provinceList;
            Store4.DataBind();

            //物流公司数据
            var logisticsList = CodeService.GetCodeListInfoByCodeTypeID(243);

            Store7.DataSource = logisticsList;
            Store7.DataBind();
        }
Beispiel #13
0
 internal CodeBlock(int start, CodeService codeService)
 {
     this.Start   = start;
     _codeService = codeService is OffsetCodeService ols
         ? ols.WithOffset(start)
         : new OffsetCodeService(codeService, start);
 }
Beispiel #14
0
        private static void GenerateSPs()
        {
            //if (DataService.Provider == null)
            SetProvider();


            string lang    = _language;
            string fileExt = FileExtension.DOT_CS;

            if (FileExtension.IsVB(lang))
            {
                language = new VBCodeLanguage();
                fileExt  = FileExtension.DOT_VB;
            }

            //loop the providers, and if there's more than one, output to their own folder
            //for tidiness
            foreach (DataProvider provider in DataService.Providers)
            {
                //string code = usings + CodeService.RunSPs(provider.Name, language);
                string outDir = GetOutSubDir(provider);
                if (outDir == string.Empty)
                {
                    outDir = Directory.GetCurrentDirectory();
                }
                string outPath = Path.Combine(outDir, "StoredProcedures" + fileExt);
                AddLogEntry(LogState.Information, "Generating SPs to " + outPath);

                TurboTemplate tt = CodeService.BuildSPTemplate(language, provider);
                tt.OutputPath = outPath;
                turboCompiler.AddTemplate(tt);
            }

            AddLogEntry(LogState.Information, "Finished");
        }
Beispiel #15
0
        /// 初始化界面绑定
        private void InitFormValues()
        {
            dateCreateTrade.DateTime = DateTime.Now;                                     //订单时间
            dateEndTrade.DateTime    = DateTime.Now.AddDays(Constants.DEFAULT_END_DAYS); //默认为15天过后

            #region 客户名称
            cmbConsumerName.Properties.DataSource = ConsumerService.GetAllConsumer();
            cmbConsumerName.Properties.NullText   = "请选择客户";
            #endregion

            #region 收款方式
            cmbPayWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_TRADE_TYPE);
            cmbPayWay.EditValue             = Constants.DEFAULT_TRADE_TYPE;
            #endregion

            #region 销售人员
            cmbSeller.Properties.DataSource = UserService.GetAllUser();//待添加条件选择
            cmbSeller.Properties.NullText   = "请选择销售人员";
            #endregion

            #region 承担方式
            cmbStandWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_POSTFEE_OWNER);
            cmbStandWay.EditValue             = Constants.DEFAULT_POSTFEE_OWNER;
            #endregion

            #region 物流信息系列绑定
            try
            {
                cmbShippingType.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_SHIPPING_TYPE);
                cmbShippingType.EditValue             = Constants.DEFAULT_SHIPPING_TYPE;

                // 物流公司
                List <LogisticCompany> companySource = LogisticCompanyService.GetLogisticCompany(p => p.shippingType == cmbShippingType.EditValue.ToString());
                cmbShipCompany.Properties.DataSource = companySource;
                cmbShipCompany.EditValue             = companySource.FirstOrDefault(p => p.isdefault == true).code;

                //物流模板
                List <LogisticCompanyTemplate> templateSource = LogisticCompanyTemplateService.GetLogisticCompanyTemplate(p => p.LogisticCompanyCode == cmbShipCompany.EditValue.ToString());
                cmbShippingTemplate.Properties.DataSource = templateSource;
                cmbShippingTemplate.EditValue             = templateSource.FirstOrDefault().TemplateCode;
            }
            catch (Exception ex)
            {
            }

            #endregion

            #region  所属店铺
            cmbOwnerShop.Properties.DataSource = ShopService.GetAllShop();
            cmbOwnerShop.Properties.NullText   = "请选择店铺";
            cmbOwnerShop.Properties.PopupWidth = 400;
            #endregion

            radioHasTicket.EditValue = false; //默认不开票
            txtPostFee.Text          = "10";  //默认邮费为10元
            txtDiscountRate.Text     = "1.0"; //默认不打折
            txtDicountOutFee.Text    = "0.0";
            txtDiscountFee.Text      = "0.0";
        }
        public void Acc_CodeGen2_VBRunSPTemplate()
        {
            DataProvider  provider = DataService.GetInstance("NorthwindAccess");
            TurboTemplate bits     = CodeService.BuildSPTemplate(new VBCodeLanguage(), provider);

            bits.Render();
            Assert.IsTrue(bits.FinalCode.Length > 0);
        }
        public void Acc_CodeGen2_RunViewTemplate()
        {
            DataProvider  provider = DataService.GetInstance("NorthwindAccess");
            TurboTemplate bits     = CodeService.BuildViewTemplate("Current Product List", new CSharpCodeLanguage(), provider);

            bits.Render();
            Assert.IsTrue(bits.FinalCode.Length > 0);
        }
        public void CodeGen2_VBRunClassTemplate()
        {
            DataProvider  provider = DataService.GetInstance("Northwind");
            TurboTemplate bits     = CodeService.BuildClassTemplate("Products", new VBCodeLanguage(), provider);

            bits.Render();
            Assert.IsTrue(bits.FinalCode.Length > 0);
        }
        public void CodeGen2_RunStructTemplate()
        {
            DataProvider  provider = DataService.GetInstance("Northwind");
            TurboTemplate bits     = CodeService.BuildStructsTemplate(new CSharpCodeLanguage(), provider);

            bits.Render();
            Assert.IsTrue(bits.FinalCode.Length > 0);
        }
            public async void should_get_fixed_url()
            {
                var service = new CodeService();
                var result  = await service.GetRepoUrl();

                Assert.True(result.Succeeded);
                Assert.Equal(CodeService.REPO_URL, result.Value);
            }
Beispiel #21
0
        public void TestGetAllCodesEmptyTable()
        {
            ACMDbContext          context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService           codeService = new CodeService(context);
            List <Models.CodeDTO> list        = codeService.GetAllCodes();

            Assert.Empty(list);
        }
 private void BuildList(ListControl cbl, IEnumerable <string> tableList)
 {
     cbl.Items.Clear();
     foreach (string s in tableList)
     {
         if (CodeService.ShouldGenerate(s, ddlProviders.SelectedValue))
         {
             ListItem item = new ListItem(s, s);
             cbl.Items.Add(item);
         }
     }
 }
Beispiel #23
0
        public async Task TestCreateARegistrationCodeInvalidApartmentNumber()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            await context.Apartments.AddAsync(apartment1);

            await context.SaveChangesAsync();

            await Assert.ThrowsAsync <ACMException>(() => codeService.CreateARegistrationCode("0"));
        }
Beispiel #24
0
        public ActionResult AddService([Bind(Include = "Id,Code,ServiceTypeId")] CodeService codeService)
        {
            if (ModelState.IsValid)
            {
                db.CodeServices.Add(codeService);
                db.SaveChanges();
                string codeController = "";
                var    codeId         = GetCodeId(codeService.Code, out codeController);
                return(RedirectToAction("Details", codeController, new { Id = codeId }));
            }

            ViewBag.ServiceTypeId = new SelectList(db.ServiceTypes, "Id", "Name", codeService.ServiceTypeId);
            return(View(codeService));
        }
        public Object DelCode(string CodeString)
        {
            ReturnData result = new ReturnData();

            result.Msg = "";
            using (var sqlconnection = new SqlConnection(connectionString))
            {
                bool flag = true;
                if (sqlconnection.State == ConnectionState.Closed)
                {
                    sqlconnection.Open();
                }
                SqlTransaction transaction = sqlconnection.BeginTransaction();
                try
                {
                    CodeService repository = new CodeService(sqlconnection);
                    for (int i = 0; i < CodeString.Split(',').Length; i++)
                    {
                        string strCodeString = (CodeString.Split(','))[i].ToString();
                        if (!repository.DelCode((CodeString.Split(','))[i].ToString(), transaction))
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        transaction.Commit();
                        result.Result = true;
                    }
                    else
                    {
                        result.Result = false;
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    result.Msg    = ex.Message;
                    result.Result = false;
                    return(result);
                }
                finally
                {
                    sqlconnection.Close();
                }
            }
        }
Beispiel #26
0
        public async Task TestIsCodeValidFalse()
        {
            ACMDbContext     context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService      codeService = new CodeService(context);
            RegistrationCode code        = new RegistrationCode {
                Code = "code1"
            };
            await context.RegistrationCodes.AddAsync(code);

            await context.SaveChangesAsync();

            bool output = codeService.IsCodeValid("code2");

            Assert.False(output);
        }
Beispiel #27
0
        // GET: CodeServices/Delete/5
        public ActionResult Delete(int id)
        {
            CodeService codeService = db.CodeServices.Find(id);

            if (codeService == null)
            {
                return(HttpNotFound());
            }
            db.CodeServices.Remove(codeService);
            db.SaveChanges();
            string codeController = "";
            var    codeId         = GetCodeId(codeService.Code, out codeController);

            return(RedirectToAction("Details", codeController, new { Id = codeId }));
        }
Beispiel #28
0
 /// <summary>
 /// 加载付款方式
 /// </summary>
 /// <param name="comboBoxEdit"></param>
 public void GetPayType(ComboBoxEdit comboBoxEdit)
 {
     if (comboBoxEdit.Properties.Items.Count == 0)
     {
         comboBoxEdit.Properties.Items.Add("请选择");
         List <Code> payTypeList = CodeService.GetCode(c => c.CodeCategory.Trim() == "付款方式");
         foreach (Code payType in payTypeList)
         {
             comboBoxEdit.Properties.Items.Add(payType.CodeName);
         }
         if (comboBoxEdit.Properties.Items.Count >= 1)
         {
             comboBoxEdit.SelectedIndex = 0;
         }
     }
 }
        public async Task <List <GenerateOutPutDto> > GenerateCode(CodeInputDto input)
        {
            var result = new List <GenerateOutPutDto>();

            try
            {
                var createdDate = DateTime.Now;
                var codes       = await _context.RedeemCodes.Select(x => x.Code).ToListAsync();

                var type = await _context.ProductTypes.FindAsync(input.TypeId);

                type.GeneratedCount       += input.Count;
                _context.Entry(type).State = EntityState.Modified;
                if (input.Count > 0)
                {
                    for (int i = 0; i < input.Count; i++)
                    {
                        var redeemCode = new RedeemCode()
                        {
                            TypeId        = input.TypeId,
                            Code          = CodeService.GenerateNewCode(codes),
                            Status        = Domain.Enums.Status.NotActivated,
                            CreatedDate   = createdDate,
                            CreatedUserId = input.UserId
                        };
                        _context.RedeemCodes.Add(redeemCode);
                    }
                }
                await _context.SaveChangesAsync();

                var _result = await _context.RedeemCodes.Where(x => !x.VirtualDeleted && x.CreatedDate.Value == createdDate).ToListAsync();

                var __result = _result.Select(x => new GenerateOutPutDto()
                {
                    Code            = x.Code,
                    Id              = x.Id,
                    CreatedDate     = x.CreatedDate.Value.ToString(),
                    CreatedDateTime = x.CreatedDate.Value,
                    ProductType     = x.ProductType.Name
                });
                return(__result.ToList());
            }
            catch (Exception ex)
            {
                return(result);
            }
        }
 public Object Get(string ActionType, string CodeString, string RoomName, string TypeName, string Problem, string TopClass)
 {
     if (ActionType == "SelectCode")
     {
         if (CodeString != null && CodeString != "")
         {
             using (SqlConnection con = new SqlConnection(_connectionString))
             {
                 CodeService BllCode = new CodeService(con);
                 return(BllCode.GetCodeByWhere("  where CodeString like '%" + CodeString.ToUpper() + "%'"));
             }
         }
         else
         {
             return(null);
         }
     }
     else if (ActionType == "FuzzyByItem")
     {
         using (var sqlconnection = new SqlConnection(_connectionString))
         {
             CodeService repository = new CodeService(sqlconnection);
             string      strsql     = " where 1=1 ";
             if (RoomName != "" && RoomName != null)
             {
                 strsql += " and RoomName='" + RoomName + "' ";
             }
             if (TypeName != "" && TypeName != null)
             {
                 strsql += " and TypeName like '%" + TypeName + "%'";
             }
             if (Problem != "" && Problem != null)
             {
                 strsql += " and Problem like '%" + Problem + "%'";
             }
             if (TopClass != "" && TopClass != null)
             {
                 strsql += " and TopClass='" + TopClass + "'";
             }
             return(repository.GetCodeByWhere(strsql));
         }
     }
     else
     {
         return(null);
     }
 }