private async Task <List <SysUserInfo> > AddTestAccount(DimStoreModel model) { List <SysUserInfo> list = new List <SysUserInfo>(); await Task.Run(() => { for (var i = 0; i < 100; i++) { SysUserInfo entity = new SysUserInfo { //User_Account = Guid.NewGuid().ToString("N").Substring(0, 6), //User_Name = Guid.NewGuid().ToString("N").Substring(0, 6), //User_Password = model.UserPassword, //User_Org_Id = model.UserOrgId, //User_Group_Names = model.UserGroupNames, //User_Email = Guid.NewGuid().ToString("N").Substring(0, 6) + "@gmail.com", //User_Is_Ldap = model.UserIsLdap, //User_Mobile_No = model.UserMobileNo, //User_Ower = model.UserOwer, //Language_Code = model.LanguageCode, //User_Is_Lock = model.UserIsLock, //Eff_Start_Date = model.EffStartDate, //Eff_End_Date = model.EffEndDate, Creation_Date = DateTime.Now, Created_By = 1 }; list.Add(entity); } }); return(list); }
public async Task <FuncResult> Add([FromBody] DimStoreModel model) { if (!ModelState.IsValid) { return(new FuncResult() { IsSuccess = false, Message = "参数错误" }); } return(await storeService.Add(model, CurrentUser.Get().Id)); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <FuncResult> Update(int id, DimStoreModel model, int currentuserId) { DimStore entity = await _context.DimStore.FindAsync(id); if (entity == null) { return(new FuncResult() { IsSuccess = false, Message = "店铺ID错误!" }); } entity.stCode = model.stCode; entity.stRegion = model.stRegion; entity.stCity = model.stCity; entity.stLocation = model.stLocation; entity.stBrand = model.stBrand; entity.stOM = model.stOM; entity.stDM = model.stDM; entity.stName = model.stName; entity.stName_en = model.stName_en; entity.stAddress = model.stAddress; entity.stAddress_en = model.stAddress_en; entity.stType = model.stType; entity.stOpenDate = model.stOpenDate; entity.stCloseDate = model.stCloseDate; entity.stTel = model.stTel; entity.stFax = model.stFax; entity.stEmail = model.stEmail; entity.stIP = model.stIP; entity.stSpace = model.stSpace; entity.stSeat = model.stSeat; entity.stBizTime = model.stBizTime; entity.stPOST = model.stPOST; entity.stSM = model.stSM; entity.stSMTel = model.stSMTel; entity.stComments = model.stComments; entity.Last_Updated_By = currentuserId; entity.Last_Update_Date = DateTime.Now; _context.DimStore.Update(entity); await _context.SaveChangesAsync(); return(new FuncResult() { IsSuccess = true, Content = entity, Message = "修改成功" }); }
public async Task <FuncResult> Update(int id, [FromBody] DimStoreModel model) { FuncResult data = await storeService.Update(id, model, CurrentUser.Get().Id); return(data); }
public async Task <FuncResult> Add(DimStoreModel model, int currentUserId) { if (_context.DimStore.Count(e => e.stCode == model.stCode) > 0) { return(new FuncResult() { IsSuccess = false, Message = "已经存在相同的店铺编码。" }); } DimStore entity = new DimStore { stCode = model.stCode, stRegion = model.stRegion, stCity = model.stCity, stLocation = model.stLocation, stBrand = model.stBrand, stOM = model.stOM, stDM = model.stDM, stName = model.stName, stName_en = model.stName_en, stAddress = model.stAddress, stAddress_en = model.stAddress_en, stType = model.stType, stOpenDate = model.stOpenDate, stCloseDate = model.stCloseDate, stTel = model.stTel, stFax = model.stFax, stEmail = model.stEmail, stIP = model.stIP, stSpace = model.stSpace, stSeat = model.stSeat, stBizTime = model.stBizTime, stPOST = model.stPOST, stSM = model.stSM, stSMTel = model.stSMTel, stComments = model.stComments, Creation_Date = DateTime.Now, Created_By = currentUserId }; await _context.DimStore.AddAsync(entity); using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction trans = _context.Database.BeginTransaction()) { try { await _context.SaveChangesAsync(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); return(new FuncResult() { IsSuccess = false, Content = ex.Message }); } } return(new FuncResult() { IsSuccess = true, Content = entity, Message = "添加成功" }); }