public bool Create(VM.RoleInfoItem model, List <MVC2015.Web.Model.SystemMaint.Module.ModulePermission> ModulePermissions) { MD.tbl_Common_Role mdRoleModel = new MD.tbl_Common_Role(); mdRoleModel.Name = model.Name; mdRoleModel.Description = model.Description; mdRoleModel.CreatedBy = model.CreatedBy; mdRoleModel.CreatedDate = DateTime.Now; Ctx.tbl_Common_Role.Add(mdRoleModel); Ctx.SaveChanges(); //添加角色权限列表 CreatePermission(ConvertToRolePermission(mdRoleModel.RoleId, model.CreatedBy, ModulePermissions)); Ctx.SaveChanges(); return(true); }
public void Save(VM.FileItem item) { var entity = new MD.tbl_Attachment() { AttachmentGuid = item.FileGuid, FileName = item.FileName, FileContent = item.FileContent, FileSize = item.FileSize, Description = item.Description, IsDeleted = false, CreatedBy = item.CreatedBy, CreatedDate = item.CreatedDate }; Ctx.tbl_Attachment.Add(entity); Ctx.SaveChanges(); }
public bool ResetPassword(string name, string emailTo) { MD.tbl_Common_User date = Ctx.tbl_Common_User.First(u => u.LogonName == name); IPasswordPolicy Password = new RandomPassword(); string orginalPassword = Password.GeneratePassword(); date.Password = HashEncrypt.SHA512Encrypt(orginalPassword); date.UpdatedBy = null; date.UpdatedDate = null; Ctx.SaveChanges(); //发送邮件 SendEmail(date, orginalPassword, "User_ResetPassword", emailTo); return(true); }
public bool Update(VM.CompanyModel model, string allSelectList, int currCompanyId, string logonName) { MD.tbl_Company company = Ctx.tbl_Company.First(c => c.ID == model.ID && c.IsDeleted != true); company.Name = model.Name.Trim(); company.Code = model.Code.Trim(); company.Description = model.Description; company.ProcessingTime = DateTime.Now - DateTime.Now.AddHours(-1);; company.SendTime = DateTime.Now - DateTime.Now.AddHours(-1);; company.SendUrl = model.SendUrl; company.EmailAddress = model.EmailAddress; company.Rate = model.Rate; company.Fee = model.Fee; company.DocumentMaker = model.DocumentMaker; company.UpdatedBy = model.UpdatedBy; company.UpdatedDate = DateTime.Now; // 用户公司关系 UpdateUserCompany(allSelectList, currCompanyId, logonName); Ctx.SaveChanges(); return(true); }
public bool Create(VM.ResourceInfoItem model) { var temp = (from ri in Ctx.tbl_Common_Resource.Where(r => r.ResourceKey == model.ResourceKey) select ri).ToList(); if (temp.Count() == 0) { MD.tbl_Common_Resource data = new MD.tbl_Common_Resource(); data.ResourceKey = model.ResourceKey; data.ResourceValueZHCN = model.ResourceValueZHCN; data.ResourceValueZHHK = model.ResourceValueZHHK; data.ResourceValueENUS = model.ResourceValueENUS; data.IsDeleted = null; data.CreatedBy = model.CreatedBy; data.CreatedDate = DateTime.Now; Ctx.tbl_Common_Resource.Add(data); Ctx.SaveChanges(); ResourceHelper.UpdateCommonResourceList(); return(true); } else if (temp.First().IsDeleted == true) { temp.First().ResourceValueENUS = model.ResourceValueENUS; temp.First().ResourceValueZHCN = model.ResourceValueZHCN; temp.First().ResourceValueZHHK = model.ResourceValueZHHK; temp.First().IsDeleted = null; temp.First().CreatedBy = model.CreatedBy; temp.First().CreatedDate = DateTime.Now; Ctx.SaveChanges(); ResourceHelper.UpdateCommonResourceList(); return(true); } else { return(false); } }
//public List<SelectListItem> GetAllGasStationSelectList() //{ // var allGasStation = (from gasStation in Ctx.tbl_Gs_GasStationInfo // where gasStation.IsDelete != true // select new SelectListItem // { // Text = gasStation.Name, // Value = gasStation.GasStationId.ToString(), // Selected = true // }); // return allGasStation.ToList(); //} public bool Create(VM.UserInfoItem model) { MD.tbl_Common_User date = new MD.tbl_Common_User(); date.UserName = model.UserName; date.LogonName = model.LogonName; //model.StatusList.First(). if (model.StrStatus.ToString() == UserStatus.Normal.strValue) { date.Status = UserStatus.Normal.intValue; } else { date.Status = UserStatus.Disable.intValue; } date.DomainAccount = model.DomainAccount; date.EmailAddress = model.EmailAddress; date.CreatedDate = DateTime.Now; date.CreatedBy = model.CreatedBy; date.UpdatedDate = DateTime.Now; date.UpdatedBy = model.UpdatedBy; //生成密码 //IPasswordPolicy Password = new RandomPassword(); //string orginalPassword = Password.GeneratePassword(); //date.Password = HashEncrypt.SHA512Encrypt(orginalPassword); date.Password = model.Password; Ctx.tbl_Common_User.Add(date); //生成角色关系 MD.tbl_Common_RoleUser roleUser = new MD.tbl_Common_RoleUser(); roleUser.RoleId = model.RoleId.Value; roleUser.UserId = date.UserId; roleUser.CreatedDate = DateTime.Now; roleUser.CreatedBy = model.CreatedBy; //roleUser.UpdatedDate = DateTime.Now; //roleUser.UpdatedBy = model.UpdatedBy; Ctx.tbl_Common_RoleUser.Add(roleUser); Ctx.SaveChanges(); //生成公司关系 updateUserOfCompany(roleUser.UserId, model.UserCompanyValue, model.CreatedBy); //生成 气站关系 // updateUserOfGasStation(roleUser.UserId, model.UserGasStationValue, model.CreatedBy); //发送邮件 //if(date.Status==1) // SendEmail(date, orginalPassword, "User_New"); return(true); }