public ActionResult Daizhen(int?p) { Pager pager = new Pager(); pager.table = "CMSCustomer"; pager.strwhere = "1=1"; pager.PageSize = 10; pager.PageNo = p ?? 1; pager.FieldKey = "CustomerId"; pager.FiledOrder = "CustomerId Desc"; pager.strwhere = pager.strwhere + " and CustomerTizhi='0'"; pager = CMSService.SelectAll("Customer", pager); List <CustomerDto> list = new List <CustomerDto>(); foreach (DataRow dr in pager.EntityDataTable.Rows) { CustomerDto dto = CustomerMapping.getDTO(dr); list.Add(dto); } pager.Entity = list.AsQueryable(); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.RecordCount = pager.Amount; ViewBag.Message = pager.Amount; return(View(pager.Entity)); }
public static IMapping CreatMapping(string DtoName) { IMapping Mapping = null; if (DtoName == "User") { Mapping = new UserMapping(); } if (DtoName == "Role") { Mapping = new RoleMapping(); } if (DtoName == "Category") { Mapping = new CategoryMapping(); } if (DtoName == "Article") { Mapping = new ArticleMapping(); } if (DtoName == "Image") { Mapping = new ImageMapping(); } if (DtoName == "Customer") { Mapping = new CustomerMapping(); } if (DtoName == "Tizhi") { Mapping = new TizhiMapping(); } if (DtoName == "Xueya") { Mapping = new XueyaMapping(); } if (DtoName == "Jianyan") { Mapping = new JianyanMapping(); } if (DtoName == "Chufang") { Mapping = new ChufangMapping(); } if (DtoName == "Jixiao") { Mapping = new JixiaoMapping(); } if (DtoName == "Fankui") { Mapping = new FankuiMapping(); } if (DtoName == "Yuyue") { Mapping = new YuyueMapping(); } return(Mapping); }
public void Should_change_update_check_to_never() { var mapping = new CustomerMapping(); mapping.Map(x => x.Surname); modification.ApplyTo(mapping); var columnMapping = ((IMapping)mapping).Mappings.Single().CastTo<IColumnMapping>(); Assert.That(columnMapping.Attributes["UpdateCheck"], Is.EqualTo("Never")); }
/// <summary> /// 更新CustomerMapping信息 /// </summary> public void UpdateCustomerMapping(CustomerMapping entity) { IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>(); //new DataCommand("CustomerCheckTelIsExist"); cmd.CreateCommand("UpdateCustomerMapping"); //DataCommand cmd = new DataCommand("UpdateCustomerMapping"); cmd.SetParameter <CustomerMapping>(entity); cmd.ExecuteNonQuery(); }
public static string CustomerIdToName(string strWhere) { CustomerDto dto = new CustomerDto(); DataTable dt = CMSService.SelectOne("Customer", "CMSCustomer", strWhere); foreach (DataRow dr in dt.Rows) { dto = CustomerMapping.getDTO(dr); } return(dto.CustomerName); }
public void Should_change_update_check_to_never() { var mapping = new CustomerMapping(); mapping.Map(x => x.Surname); modification.ApplyTo(mapping); var columnMapping = ((IMapping)mapping).Mappings.Single().CastTo <IColumnMapping>(); Assert.That(columnMapping.Attributes["UpdateCheck"], Is.EqualTo("Never")); }
public static List <OrderViewModel> SerializeOrdersToViewModels(IEnumerable <Order> orders) { return(orders.Select(order => new OrderViewModel { Id = order.Id, CreatedOn = order.DateCreated, UpdatedOn = order.DateUpdated, OrderItems = SerializeSalesOrderItems(order.OrderItems), Customer = CustomerMapping.SerializeCustomer(order.Customer), IsPaid = order.IsPaid }).ToList()); }
public async Task <ActionResult> Edit(int id) { CustomerViewModel model = new CustomerViewModel(); TEBApiResponse apiResponse = await Get("/Customer/GetCustomerById?Id=" + id); if (apiResponse.IsSuccess) { Customer customer = JsonConvert.DeserializeObject <Customer>(Convert.ToString(apiResponse.Data)); model = CustomerMapping.ModelToView(customer); } return(View(model)); }
/// <summary> /// 获取单个CustomerMapping信息 /// </summary> public CustomerMapping LoadCustomerMapping(string openid, int thridtype) { IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>(); //new DataCommand("CustomerCheckTelIsExist"); cmd.CreateCommand("LoadCustomerMapping"); //DataCommand cmd = new DataCommand("LoadCustomerMapping"); cmd.SetParameter("@OpenID", DbType.String, openid); cmd.SetParameter("@ThirdType", DbType.Int32, thridtype); CustomerMapping result = cmd.ExecuteEntity <CustomerMapping>(); return(result); }
public void It_should_return_true() { // ARRANGE var builder = Fixture.DbContextBuilder; var mapping = new CustomerMapping(); var baseType = mapping.GetType().BaseType; // ACT var result = builder.IsMappingClass(baseType); // ASSERT Assert.True(result); }
public CustomerMapping LoadCustomerMappingForCustomer(int customerSysno, int thridtype) { IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>(); //new DataCommand("CustomerCheckTelIsExist"); cmd.CreateCommand("LoadCustomerMappingForCustomer"); //DataCommand cmd = new DataCommand("LoadCustomerMappingForCustomer"); cmd.SetParameter("@CustomerSysNo", DbType.Int32, customerSysno); cmd.SetParameter("@ThirdType", DbType.Int32, thridtype); CustomerMapping result = cmd.ExecuteEntity <CustomerMapping>(); return(result); }
public ActionResult Search() { string CustomerName = Request.Form["CustomerName"].ToString(); DataTable dt = CMSService.SelectSome("Customer", "CMSCustomer", "CustomerName='" + CustomerName + "'"); List <CustomerDto> list = new List <CustomerDto>(); foreach (DataRow dr in dt.Rows) { CustomerDto dto = CustomerMapping.getDTO(dr); list.Add(dto); } ViewData["Category"] = MyService.GetCategoryList("CategoryParentId=20"); return(View(list)); }
public ActionResult CreateCustomer([FromBody] CustomerViewModel customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _logger.LogInformation("Creating a new customer"); customer.DateCreated = DateTime.UtcNow; customer.DateUpdated = DateTime.UtcNow; var customerData = CustomerMapping.SerializeCustomer(customer); var newCustomer = _customerService.CreateCustomer(customerData); return(Ok(newCustomer)); }
public ActionResult Guidang(int id) { CustomerGuidangViewModel model = new CustomerGuidangViewModel(); DataTable dt = CMSService.SelectOne("Customer", "CMSCustomer", "CustomerId=" + id); foreach (DataRow dr in dt.Rows) { CustomerDto dto = new CustomerDto(); dto = CustomerMapping.getDTO(dr); model.CustomerId = dto.CustomerId; model.CustomerName = dto.CustomerName; model.CustomerGuidang = dto.CustomerGuidang; } ViewData["ListGuidang"] = MyService.GetCategoryList("CategoryParentId=30"); return(View(model)); }
public static CustomerDTO FindId(Guid?id) { try { var customerFound = db.Customers.FirstOrDefault(x => x.Id == id); if (customerFound != null) { CustomerDTO resultCustomer = CustomerMapping.MapCustomer(customerFound); return(resultCustomer); } return(null); } catch (Exception e) { return(null); } }
/// <summary> /// Find Customer /// </summary> /// <param name="customerDTO"></param> /// <returns></returns> public static CustomerDTO Find(CustomerDTO customerDTO) { try { var customerFound = db.Customers.FirstOrDefault(x => x.Email == customerDTO.Email && x.Password == customerDTO.Password); if (customerFound != null) { CustomerDTO resultCustomer = CustomerMapping.MapCustomer(customerFound); return(resultCustomer); } return(null); } catch (Exception e) { return(null); } }
/// <summary> /// Register New Customer /// </summary> /// <param name="customer"></param> /// <returns></returns> public static bool Register(CustomerDTO customer) { try { Customer dbCustomer = CustomerMapping.MapCustomer(customer); db.Customers.Add(dbCustomer); db.SaveChanges(); } catch (DbUpdateException e) { throw new EmailAlreadyExists(); } catch (Exception e) { return(false); } return(true); }
public static CustomerDTO Edit(CustomerDTO customer) { try { var foundCustomer = db.Customers.FirstOrDefault(x => x.Id == customer.Id); foundCustomer.Address1 = customer.Address1; foundCustomer.Address2 = customer.Address2; foundCustomer.Address3 = customer.Address3; db.SaveChanges(); var foundCustomeragin = db.Customers.Find(customer.Id); CustomerDTO dbCustomer = CustomerMapping.MapCustomer(foundCustomeragin); return(dbCustomer); } catch (Exception e) { return(null); } }
public async Task <ActionResult> Create(CustomerViewModel model) { model.Username = model.FirstName + model.LastName; if (!String.IsNullOrWhiteSpace(model.Email)) { TEBApiResponse apiResponse1 = await Get("/Customer/GetCustomerByEmail?email=" + model.Email.Trim()); if (apiResponse1.Data != null) { ModelState.AddModelError("", "Email is already registered"); } } if (!String.IsNullOrWhiteSpace(model.Username)) { TEBApiResponse apiResponse2 = await Get("/Customer/GetCustomerByUsername?userName="******"", "Username is already registered"); } } if (ModelState.IsValid) { Customer customer = new Customer(); customer = CustomerMapping.ViewToModel(model); if (model.Id == 0) { TEBApiResponse apiResponse = await Post <Customer>("/Customer/InsertCustomer", customer); model.Id = Convert.ToInt32(apiResponse.Data.ToString()); } else { TEBApiResponse apiResponse = await Post <Customer>("/Customer/UpdateCustomer", customer); model.Id = 0; } } return(View(model)); }
public ActionResult GetCustomers() { _logger.LogInformation("Getting customers"); var customers = _customerService.GetCustomers(); var customerModels = customers .Select(customer => new CustomerViewModel { Id = customer.Id, FirstName = customer.FirstName, LastName = customer.LastName, Address = CustomerMapping .MapCustomerAddress(customer.Address), DateCreated = customer.DateCreated, DateUpdated = customer.DateUpdated }) .OrderByDescending(customer => customer.DateCreated) .ToList(); return(Ok(customerModels)); }
// // GET: /Customer/ public ActionResult Index(int?p, string category, string guidang) { string Category = category ?? "全部"; string Guidang = guidang ?? "0"; Pager pager = new Pager(); pager.table = "CMSCustomer"; pager.strwhere = "1=1"; pager.PageSize = 10; pager.PageNo = p ?? 1; pager.FieldKey = "CustomerId"; pager.FiledOrder = "CustomerId Desc"; if (Category != "全部") { pager.strwhere = pager.strwhere + " and charindex('" + Category + "',CustomerTizhi)>0"; } if (Guidang != "0") { pager.strwhere = pager.strwhere + " and charindex('" + Guidang + "',CustomerGuidang)>0"; } pager = CMSService.SelectAll("Customer", pager); List <CustomerDto> list = new List <CustomerDto>(); foreach (DataRow dr in pager.EntityDataTable.Rows) { CustomerDto dto = CustomerMapping.getDTO(dr); list.Add(dto); } pager.Entity = list.AsQueryable(); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.RecordCount = pager.Amount; ViewBag.Message = pager.Amount; ViewData["Category"] = MyService.GetCategoryList("CategoryParentId=20"); ViewData["Guidang"] = MyService.GetCategoryList("CategoryParentId=30"); return(View(pager.Entity)); }
public ActionResult Edit(int id) { CustomerEditViewModel model = new CustomerEditViewModel(); DataTable dt = CMSService.SelectSome("Customer", "CMSCustomer", "CustomerId=" + id); foreach (DataRow dr in dt.Rows) { CustomerDto dto = CustomerMapping.getDTO(dr); model.CustomerName = dto.CustomerName; model.CustomerNumber = dto.CustomerNumber; model.CustomerBirthday = dto.CustomerBirthday.ToShortDateString(); model.CustomerSex = dto.CustomerSex; model.CustomerId = dto.CustomerId; model.CustomerTelephone = dto.CustomerTelephone; model.CustomerEmail = dto.CustomerEmail; model.CustomerMinzu = dto.CustomerMinzu; model.CustomerChangzhu = dto.CustomerChangzhu; model.CustomerWenhua = dto.CustomerWenhua; model.CustomerHunyin = dto.CustomerHunyin; model.CustomerZhiye = dto.CustomerZhiye; model.CustomerAddress = dto.CustomerAddress; model.CustomerHujiAddress = dto.CustomerHujiAddress; model.CustomerXiangzhen = dto.CustomerXiangzhen; model.CustomerJuweihui = dto.CustomerJuweihui; model.CustomerLianxiren = dto.CustomerLianxiren; model.CustomerLianxirenTel = dto.CustomerLianxirenTel; model.CustomerBeizhu = dto.CustomerBeizhu; model.CustomerYongyao = dto.CustomerYongyao; model.CustomerShequ = dto.CustomerShequ; model.CustomerDoctor = dto.CustomerDoctor; } ViewData["CChangzhu"] = CustomerService.GetChangzhuSelectList(); ViewData["CHunyin"] = CustomerService.GetHunyinSelectList(); ViewData["CMinzu"] = CustomerService.GetMinzuSelectList(); ViewData["CZhiye"] = CustomerService.GetZhiyeSelectList(); ViewData["CWenhua"] = CustomerService.GetWenhuaSelectList(); ViewData["Category"] = MyService.GetCategorySelectList("CategoryParentId=36"); ViewData["Doctor"] = MyService.GetUserSelectList("charindex('47',UserRoles)>0"); return(View(model)); }
public ActionResult Details(int id) { TizhiDto dto = new TizhiDto(); DataTable dt = CMSService.SelectOne("Tizhi", "CMSTizhi", "TizhiId=" + id); foreach (DataRow dr in dt.Rows) { dto = TizhiMapping.getDTO(dr); } CustomerDto cDto = new CustomerDto(); DataTable CustomerDt = CMSService.SelectOne("Customer", "CMSCustomer", "CustomerId=" + dto.TizhiCustomerId); foreach (DataRow cdr in CustomerDt.Rows) { cDto = CustomerMapping.getDTO(cdr); } ViewBag.CustomerName = cDto.CustomerName; ViewBag.CustomerSex = cDto.CustomerSex; ViewBag.CustomerBirthday = cDto.CustomerBirthday.ToShortDateString(); return(View(dto)); }
/// <summary> /// 重写自定义Map配置 /// </summary> /// <param name="modelBuilder"></param> protected override void OnModelCreating(ModelBuilder modelBuilder) { CustomerMapping.MappingToTable(modelBuilder); }
public ActionResult Index(string id, string cid) { string CustomerName = ""; string CustomerSex = ""; string CustomerBirthday = ""; DataTable dt = CMSService.SelectOne("Customer", "CMSCustomer", "CustomerId=" + cid); foreach (DataRow dr in dt.Rows) { CustomerDto dto = new CustomerDto(); dto = CustomerMapping.getDTO(dr); CustomerName = dto.CustomerName; CustomerSex = dto.CustomerSex; CustomerBirthday = dto.CustomerBirthday.ToShortDateString(); } string result = id; string[] tizhi = result.Split(','); int i = 0; int yangxuzhi = 0; for (i = 0; i < 7; i++) { yangxuzhi = yangxuzhi + int.Parse(tizhi[i]); } int yangxuzhiresult = ((yangxuzhi - 7) * 100) / (7 * 4); int yinxuzhi = 0; for (i = 7; i < 15; i++) { yinxuzhi = yinxuzhi + int.Parse(tizhi[i]); } int yinxuzhiresult = ((yinxuzhi - 8) * 100) / (8 * 4); int qixuzhi = 0; for (i = 15; i < 23; i++) { qixuzhi = qixuzhi + int.Parse(tizhi[i]); } int qixuzhiresult = ((yinxuzhi - 8) * 100) / (8 * 4); int tanshizhi = 0; for (i = 23; i < 31; i++) { tanshizhi = tanshizhi + int.Parse(tizhi[i]); } int tanshizhiresult = ((tanshizhi - 8) * 100) / (8 * 4); int shirezhi = 0; for (i = 31; i < 38; i++) { shirezhi = shirezhi + int.Parse(tizhi[i]); } if (CustomerSex == "男") { shirezhi = shirezhi - int.Parse(tizhi[36]); } if (CustomerSex == "女") { shirezhi = shirezhi - int.Parse(tizhi[37]); } //如果是男的减去36项,如果是女的减去37项 int shirezhiresult = ((shirezhi - 6) * 100) / (6 * 4); int xueyuzhi = 0; for (i = 38; i < 45; i++) { xueyuzhi = xueyuzhi + int.Parse(tizhi[i]); } int xueyuzhiresult = ((xueyuzhi - 7) * 100) / (7 * 4); int qiyuzhi = 0; for (i = 45; i < 52; i++) { qiyuzhi = qiyuzhi + int.Parse(tizhi[i]); } int qiyuzhiresult = ((qiyuzhi - 7) * 100) / (7 * 4); int tebingzhi = 0; for (i = 52; i < 59; i++) { tebingzhi = tebingzhi + int.Parse(tizhi[i]); } int tebingzhiresult = ((tebingzhi - 7) * 100) / (7 * 4); int pinghezhi = 0; for (i = 59; i < 67; i++) { pinghezhi = pinghezhi + int.Parse(tizhi[i]); } int pinghezhiresult = ((pinghezhi - 7) * 100) / (7 * 4); string Customertizhi = ""; if (yangxuzhiresult < 30 && yinxuzhiresult < 30 && qixuzhiresult < 30 && tanshizhiresult < 30 && shirezhiresult < 30 && xueyuzhiresult < 30 && qiyuzhiresult < 30 && tebingzhiresult < 30 && pinghezhiresult > 60) { Customertizhi = "平和质"; } else { if (yangxuzhiresult >= 40) { Customertizhi += "阳虚质,"; } if (yinxuzhiresult >= 40) { Customertizhi += "阴虚质,"; } if (qixuzhiresult >= 40) { Customertizhi += "气虚质,"; } if (tanshizhiresult >= 40) { Customertizhi += "痰湿质,"; } if (shirezhiresult >= 40) { Customertizhi += "湿热质,"; } if (xueyuzhiresult >= 40) { Customertizhi += "血瘀质,"; } if (qiyuzhiresult >= 40) { Customertizhi += "气淤质,"; } if (tebingzhiresult >= 40) { Customertizhi += "特禀质,"; } } if (!String.IsNullOrEmpty(Customertizhi)) { Customertizhi = Customertizhi.Substring(0, Customertizhi.Length - 1); } string Customerqinxiangtizhi = ""; if (yangxuzhiresult > 30 && yangxuzhiresult < 40) { Customerqinxiangtizhi += "阳虚质,"; } if (yinxuzhiresult > 30 && yinxuzhiresult < 40) { Customerqinxiangtizhi += "阴虚质,"; } if (qixuzhiresult > 30 && qixuzhiresult < 40) { Customerqinxiangtizhi += "气虚质,"; } if (tanshizhiresult > 30 && tanshizhiresult < 40) { Customerqinxiangtizhi += "痰湿质,"; } if (shirezhiresult > 30 && shirezhiresult < 40) { Customerqinxiangtizhi += "湿热质,"; } if (xueyuzhiresult > 30 && xueyuzhiresult < 40) { Customerqinxiangtizhi += "血瘀质,"; } if (qiyuzhiresult > 30 && qiyuzhiresult < 40) { Customerqinxiangtizhi += "气淤质,"; } if (tebingzhiresult > 30 && tebingzhiresult < 40) { Customerqinxiangtizhi += "特禀质,"; } if (!String.IsNullOrEmpty(Customerqinxiangtizhi)) { Customerqinxiangtizhi = Customerqinxiangtizhi.Substring(0, Customerqinxiangtizhi.Length - 1); } string Danganhao = System.DateTime.Now.ToString("yyyyMMddhhmmss"); TizhiDto tizhiDto = new TizhiDto(); tizhiDto.TizhiYangxu = yangxuzhiresult.ToString(); tizhiDto.TizhiYinxu = yinxuzhiresult.ToString(); tizhiDto.TizhiQixu = qixuzhiresult.ToString(); tizhiDto.TizhiTanshi = tanshizhiresult.ToString(); tizhiDto.TizhiShire = shirezhiresult.ToString(); tizhiDto.TizhiQiyu = qiyuzhiresult.ToString(); tizhiDto.TizhiXueyu = xueyuzhiresult.ToString(); tizhiDto.TizhiTebing = tebingzhiresult.ToString(); tizhiDto.TizhiPinghe = pinghezhiresult.ToString(); tizhiDto.TizhiResult = Customertizhi; tizhiDto.TizhiCustomerId = int.Parse(cid); tizhiDto.TizhiTime = System.DateTime.Now; tizhiDto.TizhiNumber = Danganhao; tizhiDto.TizhiImg = "/tizhiresult/" + Danganhao + ".png"; //ViewBag.yangxuzhiresult = yangxuzhiresult; //ViewBag.yinxuzhiresult = yinxuzhiresult; //ViewBag.qixuzhiresult = qixuzhiresult; //ViewBag.tanshizhiresult = tanshizhiresult; //ViewBag.shirezhiresult = shirezhiresult; //ViewBag.xueyuzhiresult = xueyuzhiresult; //ViewBag.qiyuzhiresult = qiyuzhiresult; //ViewBag.tebingzhiresult = tebingzhiresult; //ViewBag.pinghezhiresult = pinghezhiresult; string JsonString = JsonHelper.JsonSerializerBySingleData(tizhiDto); Message msg = CMSService.Insert("Tizhi", JsonString); msg = CMSService.UpdateFieldOneByOne("Customer", "CMSCustomer", "CustomerId=" + cid, "CustomerTizhi", Customertizhi); ViewBag.CustomerBirthday = CustomerBirthday; ViewBag.CustomerName = CustomerName; ViewBag.CustomerSex = CustomerSex; ViewBag.Customerqinxiangtizhi = Customerqinxiangtizhi; ViewBag.Customertizhi = Customertizhi; ViewBag.Danganhao = Danganhao; //ViewBag.userId = cid; return(View(tizhiDto)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { CustomerMapping.Create().Map(modelBuilder); }