public virtual CommonComment GetByCode(string code) { using (var db = new Entities()) { return db.CommonComment.FirstOrDefault(q => q.ModuleCode.ToUpper() == code.ToString().ToUpper()); } }
public BaseModule GetById(long id) { using (var db = new Entities()) { return db.BaseModule.FirstOrDefault(q => q.ID == id && q.Valid); } }
public BaseModule Add(BaseModule entity) { using (var db = new Entities()) { if (!CheckModule(entity, db)) { entity.CreateDate = DateTime.Now; entity.CreateUserID = CurrentUserBiz.CurrentUser == null ? 0 : CurrentUserBiz.CurrentUser.ID; entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser == null ? 0 : CurrentUserBiz.CurrentUser.ID; db.BaseModule.Add(entity); Errors = db.GetErrors(); if (!HasError) { try { db.SaveChanges(); } catch (Exception e) { ParseErrors(e); } } } return entity; } }
public CreateModel Edit(CreateModel entity) { using (var db = new Entities()) { if (db.CreateModel.Any(q => q.CreateUser == entity.CreateUser)) { var entry = db.Entry(entity); entry.State = EntityState.Unchanged; var regCode = RegistryCodeHelper.GenRegistryCode(entity.CreateUser); if (regCode == entity.CreateModelCode) { entry.Property(q => q.CreateModelCode).IsModified = true; Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } else { Errors.Set("Error", "注册码不匹配"); } } return entity; } }
public UserRole Edit(UserRole entity) { using (var db = new Entities()) { if (!CheckUserRole(entity, db)) { entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser.ID; var oldObject = db.UserRole.FirstOrDefault(q => q.Status == (int) StatusEnum.Valid && q.ID == entity.ID); if (oldObject != null) { entity.CopyToOnly(oldObject, q => q.RoleName, q => q.Status, q => q.ParentID, q => q.ModifyDate, q => q.ModifyUserID); } Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public CreateModel Add(CreateModel entity) { using (var db = new Entities()) { if (db.CreateModel.Any(q => q.CreateUser == entity.CreateUser)) { return Edit(entity); } else { var regCode = RegistryCodeHelper.GenRegistryCode(entity.CreateUser); if (!string.IsNullOrEmpty(regCode)) { if (regCode.ToUpper() == entity.CreateModelCode.ToUpper()) { db.CreateModel.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } else { Errors.Set("Error", "注册码不匹配"); } } } return entity; } }
public CreateModel GetFirst() { using (var db = new Entities()) { return db.CreateModel.FirstOrDefault(); } }
public UserInfo Add(UserInfo entity) { using (var db = new Entities()) { if (CheckUser(entity, db)) { entity.CreateDate = DateTime.Now; entity.CreateUserID = CurrentUserBiz.CurrentUser == null ? 0 : CurrentUserBiz.CurrentUser.ID; entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser == null ? 0 : CurrentUserBiz.CurrentUser.ID; entity.Password = EncryPassword(entity.Password); db.UserInfo.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public IEnumerable<ManagerComment> Search(ManagerCommentCondition condition) { using (var db = new Entities()) { var id = CurrentUserBiz.CurrentUser.ID; IQueryable<ManagerComment> query = db.ManagerComment.Include(q => q.UserInfo).Where(q => q.UserID == id); if (condition.StartDate.HasValue) { var date = condition.StartDate.Value.Date; query = query.Where(q => q.ModifyDate >= date); } if (condition.EndDate.HasValue) { var date = condition.EndDate.Value.Date.AddDays(1).AddMilliseconds(-1); query = query.Where(q => q.ModifyDate <= date); } var result = query.OrderByDescending(q => q.ModifyDate).DoPage(condition.Pager).ToList(); foreach (var item in result) { item.CreateUser = db.UserInfo.FirstOrDefault(q => q.Status == (int)StatusEnum.Valid && q.ID == item.CreateUserID); item.ModifyUser = db.UserInfo.FirstOrDefault(q => q.Status == (int)StatusEnum.Valid && q.ID == item.ModifyUserID); } return result; } }
public BaseModule Edit(BaseModule entity) { using (var db = new Entities()) { if (!CheckModule(entity, db)) { entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser == null ? 0 : CurrentUserBiz.CurrentUser.ID; var oldEntity = db.BaseModule.FirstOrDefault(q => q.ID == entity.ID && q.Valid); if (oldEntity != null) { entity.CopyToExcept(oldEntity, q => q.ID, q => q.CreateDate, q => q.CreateUserID); if (!HasError) { db.SaveChanges(); } } } return entity; } }
public Comment Add(Comment entity) { using (var db = new Entities()) { if (CurrentUserBiz.CurrentUser != null) { entity.CreateDate = DateTime.Now; entity.CreateUserID = CurrentUserBiz.CurrentUser.ID; entity.ReplyID = 0; entity.UserID = CurrentUserBiz.CurrentUser.ID; entity.UserName = CurrentUserBiz.CurrentUser.UserName; entity.RoleID = CurrentUserBiz.CurrentUser.RoleID; entity.RoleName = CurrentUserBiz.CurrentUser.UserRole.RoleName; db.Comment.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } else { Errors.Set("Error", "请先登录!"); } return entity; } }
public override CommonComment Add(CommonComment entity) { using (var db = new Entities()) { if (CheckCommonComment(entity, db) && CodeList.Contains(ModuleCode.ToString())) { var date = DateTime.Now; var userId = CurrentUserBiz.CurrentUser.ID; entity.CreateDate = date; entity.CreateUserID = userId; entity.ModifyDate = date; entity.ModifyUserID = userId; entity.DiscussDate = date; entity.DiscussUserID = userId; entity.ModuleCode = ModuleCode.ToString(); db.CommonComment.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public LenLevel Add(LenLevel entity) { using (var db = new Entities()) { if (CheckRepeat(entity, db)) { Errors.Set("Error", "等级名称已经存在!"); } else { entity.CreateDate = DateTime.Now; entity.CreateUserID = CurrentUserBiz.CurrentUser.ID; entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser.ID; db.LenLevel.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public LenLevel Edit(LenLevel entity) { using (var db = new Entities()) { if (CheckRepeat(entity, db)) { Errors.Set("Error", "等级名称已经存在!"); } else { var entry = db.Entry(entity); //entry.State = EntityState.Modified; entry.State = EntityState.Unchanged; entry.Property(q => q.LevelName).IsModified = true; entry.Property(q => q.ModifyDate).IsModified = true; entry.Property(q => q.ModifyUserID).IsModified = true; Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public UserInfo GetById(long id) { using (var db = new Entities()) { return db.UserInfo.Include(q => q.UserRight).Include(q => q.UserRole).Include(q => q.LenLevel).FirstOrDefault(q => q.ID == id && q.Status == (int) StatusEnum.Valid); } }
public LenLevel GetById(long id) { using (var db = new Entities()) { return db.LenLevel.FirstOrDefault(q => q.ID == id); } }
public UserRole GetById(long id) { using (var db = new Entities()) { return db.UserRole.Include(q => q.UserRoleRight).FirstOrDefault(q => q.ID == id); } }
public ManagerComment Edit(ManagerComment entity) { using (var db = new Entities()) { if (!string.IsNullOrWhiteSpace(entity.Content)) { entity.ModifyDate = DateTime.Now; entity.ModifyUserID = CurrentUserBiz.CurrentUser.ID; entity.UserID = CurrentUserBiz.CurrentUser.ID; entity.UserName = CurrentUserBiz.CurrentUser.UserName; var entry = db.Entry(entity); entry.State = EntityState.Unchanged; entry.Property(q => q.Content).IsModified = true; entry.Property(q => q.ModifyDate).IsModified = true; entry.Property(q => q.ModifyUserID).IsModified = true; entry.Property(q => q.UserID).IsModified = true; entry.Property(q => q.UserName).IsModified = true; Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }
public ManagerComment GetById(long id) { using (var db = new Entities()) { var userId = CurrentUserBiz.CurrentUser.ID; return db.ManagerComment.FirstOrDefault(q => q.ID == id && q.UserID == userId); } }
private bool CheckRepeat(LenLevel entity, Entities db) { if (entity != null) { return db.LenLevel.Any(q => q.LevelName.ToUpper() == entity.LevelName.ToUpper() && q.ID != entity.ID); } return false; }
public Comment GetById(long id) { using (var db = new Entities()) { var entity = db.Comment.FirstOrDefault(q => q.ID == id); return entity; } }
public IEnumerable<LenLevel> Search(LevelCondition condition) { using (var db = new Entities()) { IQueryable<LenLevel> query = db.LenLevel; query = condition.Filter(query); return query.OrderBy(q => q.ID).ToList(); } }
public virtual CommonComment GetById(long id) { using (var db = new Entities()) { if (string.IsNullOrEmpty(ModuleCode.ToString())) { return null; } return db.CommonComment.FirstOrDefault(q => q.ModuleCode.ToUpper() == ModuleCode.ToString().ToUpper()); } }
public override CommonComment GetById(long id) { using (var db = new Entities()) { var entity = db.CommonComment.FirstOrDefault(q => q.ID == id); if (null != entity && CodeList.Contains(entity.ModuleCode)) { return entity; } return null; } }
public IEnumerable<CommonComment> Search(CommonCommentCondition condition) { using (var db = new Entities()) { if (!string.IsNullOrEmpty(ModuleCode.ToString().Trim()) && CodeList.Contains(ModuleCode.ToString())) { var query = db.CommonComment.Where(q => q.ModuleCode.ToUpper() == ModuleCode.ToString().ToUpper()); return query.OrderByDescending(q => q.ModifyDate).DoPage(condition.Pager).ToList(); } return new List<CommonComment>(); } }
public IEnumerable<UserInfo> Search(UserCondition condition) { using (var db = new Entities()) { var currentUser = CurrentUserBiz.CurrentUser; var query = db.UserInfo.Where(q => q.Status == (int) StatusEnum.Valid); query = condition.Filter(query); if (currentUser != null) { query = query.Where(q => q.UserType >= currentUser.UserType); } return query.OrderBy(q => q.UserCode).DoPage(condition.Pager).ToList(); } }
public IEnumerable<UserRole> Search(UserRoleCondition condition) { using (var db = new Entities()) { var query = db.UserRole.Where(q => q.Status == (int) StatusEnum.Valid); if (condition.ParentID.HasValue) { query = query.Where(q => q.ParentID == condition.ParentID.Value); } if (CurrentUserBiz.CurrentUser != null && CurrentUserBiz.CurrentUser.UserType != (int)UserTypeEnum.SuperAdmin) { query = query.Where(q => q.ParentID >= -1); } return query.OrderByDescending(q => q.ModifyDate).ToList(); } }
public IEnumerable<BaseModule> Search(ModuleCondition condition) { using (var db = new Entities()) { var query = db.BaseModule.Where(q => q.Valid); if (condition.ParentID.HasValue) { query = query.Where(q => q.ParentID == condition.ParentID.Value); } if (condition.IsBack.HasValue) { query = query.Where(q => q.IsBack == condition.IsBack.Value); } return query.OrderBy(q => q.ParentID).ThenBy(q => q.ModuleOrder).ToList(); } }
public virtual CommonComment Add(CommonComment entity) { using (var db = new Entities()) { if (!string.IsNullOrEmpty(ModuleCode.ToString())) { if (db.CommonComment.Any(q => q.ModuleCode.ToUpper() == ModuleCode.ToString().ToUpper())) { Errors.Set("Error", "该模块已经有数据!"); } else if (entity.DiscussType == (int)DiscussTypeEnum.Edit && string.IsNullOrWhiteSpace(entity.DiscussContent)) { Errors.Set("Error", "内容必须填写!"); } else if (entity.DiscussType == (int)DiscussTypeEnum.Upload && (string.IsNullOrWhiteSpace(entity.DiscussFileUrl) || string.IsNullOrWhiteSpace(entity.DiscussOfficeFileUrl))) { Errors.Set("Error", "必须上传文件!"); } else { var nowDate = DateTime.Now; var userId = CurrentUserBiz.CurrentUser.ID; entity.CreateDate = nowDate; entity.CreateUserID = userId; entity.ModifyDate = nowDate; entity.ModifyUserID = userId; entity.ModuleCode = ModuleCode.ToString(); entity.DiscussDate = nowDate; entity.DiscussUserID = userId; db.CommonComment.Add(entity); Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } } return entity; } }
public Comment Edit(Comment entity) { using (var db = new Entities()) { if (entity.ID > 0) { var entry = db.Entry<Comment>(entity); entry.State = EntityState.Unchanged; entry.Property(q => q.Content).IsModified = true; Errors = db.GetErrors(); if (!HasError) { db.SaveChanges(); } } return entity; } }