public async Task GetAllByCustomerIdAsyncShouldWorkCorrectlyWithServiceType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var customerId = Guid.NewGuid().ToString(); var orderId = Guid.NewGuid().ToString(); var model = new ServiceInfoModel { CustomerId = customerId, IsActive = true, }; var createdServiceInfo = await service.CreateAsync <ServiceInfoModel>(orderId, model, string.Empty); var serviceInfos = await service.GetAllByCustomerIdAsync <ServiceInfoModel>(customerId); Assert.Single(serviceInfos); Assert.Collection( serviceInfos, x => Assert.Equal(customerId, x.CustomerId)); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (txtName.Text == "") { CommonFunction.Alert(Literal1, "请输入服务区名称"); return; } if (ServiceInfoService.IsExist_ServiceInfo(txtName.Text)) { CommonFunction.Alert(Literal1, "该服务区名称已经存在"); return; } ServiceInfo info = new ServiceInfo(); info.S_Name = txtName.Text; info.S_Star = ddlStar.Text; info.S_Type = ddlType.Text; info.S_City = ddlCity.Text; info.S_Welcome = txtName.Text + " 欢迎您!"; info.S_HID = Convert.ToInt32(ddlGs.SelectedValue); ServiceInfoService.Insert_ServiceInfo(info); CommonFunction.Alert(Literal1, "添加成功"); txtName.Text = ""; }
public async Task GetICCAsyncShouldReturnMessageWhenRepoIsEmpty() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var sim = await service.GetICCAsync(); var count = await simRepo.All() .CountAsync(); Assert.Equal(0, count); Assert.Contains(sim, GlobalConstants.NoAvailableSimMessage); }
public async Task GetByOrderIdAsyncShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); var model = new ServiceInfoModel(); var createdServiceInfo = await service.CreateAsync <ServiceInfoModel>(orderId, model, string.Empty); var serviceInfo = await service.GetByOrderIdAsync <ServiceInfoModel>(orderId); Assert.Equal(orderId, serviceInfo.OrderId); Assert.Equal(createdServiceInfo.Id, serviceInfo.Id); }
public async Task ContractCancelAsyncShouldWorkCorrectlyWithServiceType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); var model = new ServiceInfoModel { IsActive = true, }; var createdServiceInfo = await service.CreateAsync <ServiceInfoModel>(orderId, model, string.Empty); await service.ContractCancelAsync(1, string.Empty); var serviceInfo = await service.GetByIdAsync <ServiceInfoModel>(1); Assert.False(serviceInfo.IsActive); }
private void binddata() { DataTable dt = ServiceInfoService.Get_AllServiceInfo(); GridView1.DataSource = dt; GridView1.DataKeyNames = new string[] { "S_ID" };//主键 GridView1.DataBind(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int sId = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); int rankId = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text); ServiceInfoService.Update_QuarterRank(sId, rankId); GridView1.EditIndex = -1; binddata(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CommonFunction.isLoginCheck(); DataTable dt = ServiceInfoService.Get_AllServiceInfo(); Repeater1.DataSource = dt; Repeater1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CommonFunction.isLoginCheck(); int sid = Convert.ToInt32(Request.QueryString["sid"]); ServiceInfo info = ServiceInfoService.Get_ServiceInfo(sid); SiteImg.ImageUrl = "../ServiceImg/+" + info.S_HeaderImg; ViewState["SID"] = sid; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CommonFunction.isLoginCheck(); DataTable dt = ServiceInfoService.Get_AllServiceInfo(); ddlService.DataSource = dt; ddlService.DataValueField = "S_ID"; ddlService.DataTextField = "S_Name"; ddlService.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CommonFunction.isLoginCheck(); if (Request.QueryString["sid"] != null) { ViewState["S_ID"] = Convert.ToInt32(Request.QueryString["sid"]); } else { ViewState["S_ID"] = ((UserInfo)Session["ServiceUser"]).U_SID; } ServiceInfo dtInfo = ServiceInfoService.Get_ServiceInfo(Convert.ToInt32(ViewState["S_ID"])); ViewState["dtInfo"] = dtInfo; txtName.Text = dtInfo.S_Name; ddlStar.Text = dtInfo.S_Star; BindingServices(); ddlGs.SelectedValue = dtInfo.S_HID.ToString(); ddlType.Text = dtInfo.S_Type; txtStake.Text = dtInfo.S_Stake; txtPhone.Text = dtInfo.S_Phone; txtServices.Text = dtInfo.S_Service; txtStakeNum.Text = dtInfo.S_StakeNum.ToString(); ddlCity.Text = dtInfo.S_City; txtWelcome.Text = dtInfo.S_Welcome; txtRemark.Text = dtInfo.S_Remark; txtCYRemark.Text = dtInfo.S_CYRemark; txtCSRemark.Text = dtInfo.S_CSRemark; txtZSRemark.Text = dtInfo.S_ZSRemark; txtJYZRemark.Text = dtInfo.S_JYZRemark; txtQXRemark.Text = dtInfo.S_QXRemark; txtTCSRemark.Text = dtInfo.S_TCSRemark; txtWSJRemark.Text = dtInfo.S_WSJRemark; txtFWDWRemark.Text = dtInfo.S_FWDWRemark; ImgService.ImageUrl = "../ServiceImg/" + dtInfo.S_Image; ImgCY.ImageUrl = "../ServiceImg/" + dtInfo.S_CYImage; ImgCS.ImageUrl = "../ServiceImg/" + dtInfo.S_CSImage; ImgZS.ImageUrl = "../ServiceImg/" + dtInfo.S_ZSImage; ImgJYZ.ImageUrl = "../ServiceImg/" + dtInfo.S_JYZImage; ImgQX.ImageUrl = "../ServiceImg/" + dtInfo.S_QXImage; ImgTCS.ImageUrl = "../ServiceImg/" + dtInfo.S_TCSImage; ImgWSJ.ImageUrl = "../ServiceImg/" + dtInfo.S_WSJImage; ImgFWDW.ImageUrl = "../ServiceImg/" + dtInfo.S_FWDWImage; } }
protected void btnSaveImage_Click(object sender, ImageClickEventArgs e) { if (FileUploadImg.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImg.FileName; string filePath = Server.MapPath("~/ServiceImg/" + fileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImg, Literal1, filePath, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } int result = ServiceInfoService.Update_ServiceImage(Convert.ToInt32(ViewState["SID"]), "S_HeaderImg", fileName); CommonFunction.AlertAndRedirect(Literal1, "操作成功", "SiteMainImg.aspx"); } }
public async Task GetBySearchCriteriaAsyncShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); var userId = Guid.NewGuid().ToString(); await serviceInfoRepo.AddAsync(new ServiceInfo { OrderId = orderId, Order = new Order { Id = orderId, FinishedOn = DateTime.UtcNow, UserId = userId, Status = Status.Finished, }, Service = new Service { ServiceType = ServiceType.Mobile, Name = "ASD", }, }); await serviceInfoRepo.SaveChangesAsync(); var serviceInfo = (await serviceInfoRepo.All() .FirstOrDefaultAsync()).To <ServiceInfoSearchModel>(); var serviceInfos = await service.GetBySearchCriteriaAsync <ServiceInfoModel, ServiceInfoSearchModel>(serviceInfo); Assert.Single(serviceInfos); Assert.Collection( serviceInfos, x => Assert.Equal(orderId, x.OrderId)); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (txtName.Text.Trim() != "") { DataTable dt = ServiceInfoService.Get_ServiceInfoByName(txtName.Text); Repeater1.DataSource = dt; Repeater1.DataBind(); } else { DataTable dt = ServiceInfoService.Get_AllServiceInfo(); Repeater1.DataSource = dt; Repeater1.DataBind(); } }
/// <summary> /// 上传服务队伍图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnFWDW_Click(object sender, ImageClickEventArgs e) { string fileName = CommonFunction.Get_DynamicString() + FileUploadFWDW.FileName; string vfileName = "v_" + fileName; string filePath = Server.MapPath("~/ServiceImg/" + fileName); string vfilePath = Server.MapPath("~/ServiceImg/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadFWDW, Literal1, filePath, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(filePath, vfilePath, 600, 480, "W"); System.IO.File.Delete(filePath); ServiceInfoService.Update_ServiceImage(Convert.ToInt32(ViewState["S_ID"]), "S_FWDWImage", vfileName); ImgFWDW.ImageUrl = "../ServiceImg/" + vfileName; }
void binddata() { DataTable dt = ServiceInfoService.Get_AllServiceInfo(); AspNetPager1.RecordCount = dt.Rows.Count; if (dt.Rows.Count >= 0) { PagedDataSource ps = new PagedDataSource(); DataView dv = new DataView(dt); ps.DataSource = dv; ps.AllowPaging = true; ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; ps.PageSize = AspNetPager1.PageSize; GridView1.DataSource = ps; GridView1.DataBind(); } }
/// <summary> /// 保存服务区基本信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveInfo_Click(object sender, ImageClickEventArgs e) { if (txtStake.Text.Trim() == "") { CommonFunction.Alert(Literal1, "请输入里程桩号"); return; } if (txtStakeNum.Text.Trim() == "") { CommonFunction.Alert(Literal1, "请输入里程数"); return; } if (!CommonFunction.Is_Nonnegative(txtStakeNum.Text.Trim())) { CommonFunction.Alert(Literal1, "里程数为非负值"); return; } ServiceInfo dtInfo = (ServiceInfo)ViewState["dtInfo"]; dtInfo.S_Star = ddlStar.Text; dtInfo.S_HID = Convert.ToInt32(ddlGs.SelectedValue); dtInfo.S_Type = ddlType.Text; dtInfo.S_Stake = txtStake.Text; dtInfo.S_Phone = txtPhone.Text; dtInfo.S_Service = txtServices.Text; dtInfo.S_StakeNum = Convert.ToDouble(txtStakeNum.Text); dtInfo.S_City = ddlCity.Text; dtInfo.S_Welcome = txtWelcome.Text.Trim(); dtInfo.S_Remark = txtRemark.Text; dtInfo.S_CYRemark = txtCYRemark.Text; dtInfo.S_CSRemark = txtCSRemark.Text; dtInfo.S_ZSRemark = txtZSRemark.Text; dtInfo.S_JYZRemark = txtJYZRemark.Text; dtInfo.S_QXRemark = txtQXRemark.Text; dtInfo.S_TCSRemark = txtTCSRemark.Text; dtInfo.S_WSJRemark = txtWSJRemark.Text; dtInfo.S_FWDWRemark = txtFWDWRemark.Text; ServiceInfoService.Update_ServiceBasicInfo(dtInfo); ViewState["dtInfo"] = dtInfo; CommonFunction.Alert(Literal1, "修改成功"); }
public async Task GetBySearchCriteriaAsyncShouldWorkCorrectlyWithServiceType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); var userId = Guid.NewGuid().ToString(); await serviceInfoRepo.AddAsync(new ServiceInfo { OrderId = orderId, Service = new Service { ServiceType = ServiceType.Mobile, }, }); await serviceInfoRepo.SaveChangesAsync(); var serviceInfo = (await serviceInfoRepo.All() .FirstOrDefaultAsync()).To <ServiceInfoSearchModel>(); if (serviceInfo.OrderStatus == "0") { serviceInfo.OrderStatus = null; } serviceInfo.OrderCreatedOn = null; var serviceInfos = await service.GetBySearchCriteriaAsync <InputOrderSearchModel, ServiceInfoSearchModel>(serviceInfo); Assert.Single(serviceInfos); }
public async Task SetServiceAsActiveAsyncShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); await simRepo.AddAsync(new SimCard { ICC = "89359032201234567890", }); await simRepo.SaveChangesAsync(); var model = new ServiceInfoModel { ICC = "89359032201234567890", }; var serviceInfo = await service.CreateAsync <ServiceInfoModel>(orderId, model, string.Empty); await service.SetServiceAsActiveAsync(serviceInfo.Id); var serviceInfoForComp = await serviceInfoRepo.All() .FirstOrDefaultAsync(x => x.Id == serviceInfo.Id); var sims = await simRepo.All().ToListAsync(); Assert.True(serviceInfoForComp.IsActive); Assert.Empty(sims); }
public async Task GetICCAsyncShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var iccList = new List <string> { "89359032201234567895", "89359032201234567890", }; await simRepo.AddAsync(new SimCard { ICC = "89359032201234567895", }); await simRepo.AddAsync(new SimCard { ICC = "89359032201234567890", }); await simRepo.SaveChangesAsync(); var sim = await service.GetICCAsync(); var allSims = await simRepo.All().Where(x => !x.IsDeleted).ToListAsync(); Assert.Single(allSims); Assert.Contains(sim, iccList); }
public async Task ExistByIdAsyncShouldReturnFalseWhenDoesNotExists() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var serviceInfoRepo = new EfDeletableEntityRepository <ServiceInfo>(dbContext); var simRepo = new EfDeletableEntityRepository <SimCard>(dbContext); var moqServiceNumberService = new Mock <IServiceNumberService>(); var service = new ServiceInfoService( serviceInfoRepo, simRepo, moqServiceNumberService.Object); var orderId = Guid.NewGuid().ToString(); var model = new ServiceInfoModel(); var createdServiceInfo = await service.CreateAsync <ServiceInfoModel>(orderId, model, string.Empty); Assert.False(await service.ExistByIdAsync(2)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["serviceid"] != null) { int ServiceId = Convert.ToInt32(Request.QueryString["serviceid"]); ServiceInfo serviceinfo = ServiceInfoService.Get_ServiceInfo(ServiceId); if (serviceinfo != null) { Session["serviceinfo"] = serviceinfo; Response.Redirect("index.aspx"); } else { Response.Redirect("ServiceList.aspx"); } } else { Response.Redirect("ServiceList.aspx"); } } }
public override void HandledEntity(QueueLoadEntity entity) { ServiceInfoService.ModifyQueueLoad(entity); }
/// <summary> /// Handleds the entity. /// </summary> /// <param name="entity">The entity.</param> public override void HandledEntity(TransferVelocityEntity entity) { ServiceInfoService.ModifyTransferVelocity(entity); }
/// <summary> /// Handleds the entity. /// </summary> /// <param name="entity">The entity.</param> public override void HandledEntity(HeartBeatEntity entity) { ServiceInfoService.ModifyStatus(entity); }
/// <summary> /// Handleds the entity. /// </summary> /// <param name="entity">The entity.</param> public override void HandledEntity(HealthEntity entity) { ServiceInfoService.ModifyHealthInfo(entity); }
public override void HandledEntity(ProcessingVelocityEntity entity) { ServiceInfoService.ModifyProcessingVelocity(entity); }
/// <summary> /// Handleds the entity. /// </summary> /// <param name="entity">The entity.</param> public override void HandledEntity(ServiceInfoEntity entity) { ServiceInfoService.ModifyServiceQueues(entity); }
/// <summary> /// Handleds the entity. /// </summary> /// <param name="entity">The entity.</param> public override void HandledEntity(MessageTypesEntity entity) { ServiceInfoService.ModifyMessageTypes(entity); }