public bool AddAdminRole(AdminRoleDto dto) { if (!this.db.AdminRoles.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.AdminRoles.Add(new AdminRole { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, Name = dto.Name, Description = dto.Description }); this.db.SaveChanges(); return true; } return false; }
public bool UpdateAdminRole(AdminRoleDto dto) { var adminRole = this.db.AdminRoles.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (adminRole != null) { adminRole.UpdatedOn = DateTime.Now; adminRole.UpdatedBy = dto.UpdatedBy; adminRole.Comment = dto.Comment; adminRole.Name = dto.Name; adminRole.Description = dto.Description; this.db.SaveChanges(); return true; } return false; }